因此,我正在爲uni製作一個電子商務網站,並且一切都很好,直到我實際嘗試在Chrome中查看網站。本質上,我從單一的MySQL產生一個表。我遇到的問題超出了表格的位置。不要讓代碼亂成一團。我在添加東西之間。PHP回聲問題,顯示不正確
<?php $command='select * from products' ; $runCommand=m ysqli_query($connection, $command); if (mysqli_num_rows($runCommand)>0){ echo "
<form id=\ "shoppingcart\" action=\ "cart.php\" method=\ "post\">"; echo "
<table>"; echo "
<thead>"; echo "
<tr>"; echo "
<th scope=\ "col\">Image</th>"; echo "
<th scope=\ "col\">Item</th>"; echo "
<th scope=\ "col\">Qty</th>"; echo "
<th scope=\ "col\">UpdatedQty</th>"; echo "
<th scope=\ "col\">Price</th>"; echo "</tr>"; echo "</thead>"; while($ROWVARIABLE= mysqli_fetch_assoc($runCommand)) { //line BROKE goes here //need an if quantity=0 then don't print the bunch we have under here...// echo "
<tr>"; echo "
<td>
<img src='". $ROWVARIABLE["image"]. "' alt='". $ROWVARIABLE["decription"]. "' height='200' '</img></td>"; //this is still one line, don't flip shit. It 's the img with a hover over Decription
\t \t \t echo "<td>". $ROWVARIABLE["name"]. "</td>"; //Item
\t \t \t echo "<td>".newID[$ROWVARIABLE["ID"]]."</td>"; //Quantity
\t \t \t echo "<td><select name=\"updateQ\" id=\"updateQ\">"; //Updated Quantity
\t \t \t echo "<option selected=\"selected\">No change</option>";
\t \t \t echo "<option>1</option>";
\t \t \t echo "<option>2</option>";
\t \t \t echo "<option>3</option>";
\t \t \t echo "<option>4</option>";
\t \t \t echo "<option>5</option>";
\t \t \t echo "<option>6</option>";
\t \t \t echo "<option>7</option>";
\t \t \t echo "<option>8</option>";
\t \t \t echo "<option>9</option>";
\t \t \t echo "</select>";
\t \t \t echo "</td>";
\t \t \t //BROKE 2.0
\t \t \t // Gotta fix this ^^ line to display £Price of all units added(£Price of one unit)
\t \t \t
\t \t }
\t echo "</table>";
\t echo "</br>";
\t }
\t else{
\t \t echo "Table broken, pls stahp!";
\t }
\t ?>
如果您運行的代碼片段,它拋出了一堆表格上面的回聲,我不知道爲什麼或如何解決它。我想這可能是一個菜鳥錯誤,但我真的很恐慌。該文件保存爲.php
,我用<!DOCTYPE html>
開始文件。這是我的文件頂部附近
<?php $connection = mysqli_connect(the stuff I need to connect.); ?>
認爲這是相關的。
https://gyazo.com/0dd6a3d7b025133c5b061e6af06f1091
只要查看問題代碼中的顏色突出顯示,就可以快速瞭解發生了什麼問題。 –
截圖看起來像PHP沒有處理。這裏的代碼看起來格式不正確。 – chris85
Notepad ++ ot NetBeans會告訴你錯誤在哪裏。 – mitkosoft