0
我想先將結果存儲在變量中,以便我可以使用它們,但這不會迭代任何東西。請參閱我試圖先將變量的值存儲在變量中,然後在表中的td中調用它們,但它什麼也沒有顯示。我想存儲變量的值,然後顯示在表格中,但這不起作用
它有語法錯誤什麼的。可以先存儲變量的方法是什麼?
$query_test = "SELECT itemname, categoryname, manufacturername,
price, shopname,itemurl, itemimage, typename
FROM prices p,
items i,
shops s,
categories c,
manufacturers m,
types t,
modules mo
WHERE p.shopid=s.shopid
AND i.categoryid=c.categoryid
AND p.itemid=i.itemid
AND i.ManufacturerId=m.ManufacturerID
AND i.ModuleId= mo.ModuleID
AND i.TypeId=t.TypeID
AND i.categoryid=1004
AND s.shopid=5003";
$result = mysqli_query($conn, $query_test);
echo "<table border='1'>";
echo "<tr><td>"."Name"."</td>";
echo "<td>"."Category"."</td>";
echo "<td>"."Manufacturer"."</td>";
echo "<td>"."Price"."</td>";
echo "<td>"."Shop"."</td>";
echo "<td>"."Type"."</td>";
while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {
//output a row here
$name = $row['itemname'];
$category = $row['categoryname'];
$manufacturer = $row['manufacturername'];
$price = $row['price']:
$shop = $row['shopname'];
$type = $row['typename'];
echo "<tr><td>".$name."</td>";
echo "<td>".$category."</td>";
echo "<td>".$manufacturer."</td>";
echo "<td>".$price."</td>";
echo "<td>".$shop."</td>";
echo "<td>".$type."</td></tr>";
/*echo "<tr><td>".($row['itemname'])."</td>";
echo "<td>".($row['categoryname'])."</td>";
echo "<td>".($row['manufacturername'])."</td>";
echo "<td>".($row['price'])."</td>";
echo "<td>".($row['shopname'])."</td>";
echo "<td>".($row['typename'])."</td></tr>";*/
}
echo "</table>";
如果還是不行,那麼很可能是你的查詢沒有工作,沒有行輸出 – RiggsFolly
沒有你檢查你的查詢是否實際返回任何東西或者如果代碼執行完畢? **什麼**什麼都不顯示?整個html不顯示?或者只是你希望你的查詢結果是? –
請顯示你的更多代碼!你從哪裏查詢這個數據 – RiggsFolly