我試圖顯示從數據庫列表顯示,但運行時的代碼它說:「你有沒有在你的數據中列出的產品呢。」但是實際上從我的數據列表...不是從數據庫
<?php
$con = new mysqli("localhost", "root", "3250", "shopone");
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// This block grabs the whole list of product for viewing
$product_list = "";
$sql = "SELECT * FROM product ORDER BY product_id DESC";
$result=mysqli_query($con,$sql);
while($row = mysqli_fetch_array($result)){
$product_id = $row["product_id"];
$product_name = $row["product_name"];
$product_category = $row["product_category"];
$product_retail_price = $row["product_retail_price"];
$product_price = $row["product_price"];
$product_detail = $row["product_detail"];
$product_image = $row["screenshot"];
$product_thumbnail = $row["product_thumbnail"];
$product_discount = $row["product_discount"];
$screenshot = $row["screenshot"];
$product_list .= '<table width="80%" border="1">
<tr>
<td width="172" valign="top"> echo <img src="' . GW_UPLOADPATH . $screenshot .'" width="111" height="149" alt="<?php echo $product_name; ?>" /><br />
<a href="../product_images/<?php echo $product_id; ?>.jpg">View Full Size Image</a></td>
<td width="85" class="product-text">' . $product_id . '</td>
<td width="402" class="product-text">' . $product_name . '</td>
<td width="108" align="center" class="product-text">' . $product_price . '</td>
<td width="34" align="center" class="product-text"><a rel="leanModal" href="edit_product.php?pid=' . $product_id . '">Edit</a></td>
<td width="56" align="center" class="product-text"><a rel="leanModal" href="product.php?deleteid=' . $product_id . '">Delete</a></td>
<td width="56" align="center" class="product-text"><a href="view_product.php?pid=' . $product_id . '">View</a></td>
</tr>
</table> ';
}
$product_list = "You have no product listed in your data yet";
?>
然後我得到的結果是沒有顯示它說「你的數據中沒有產品列表」,我該如何解決這個問題!
您正在您的變量中創建您的表格,然後用該消息覆蓋它。 – Mihai
另外你不需要該表中的php標籤。 – Mihai