一切都正确连接,我有一个产品报价表,通过“product_id”链接到我的产品表。我刚刚在产品报价表中添加了一个新报价,它运行良好,但该新报价尚未在前端网站上更新。
报价表仍然只显示三个在报价的产品,而不是四个!
这是报价表的代码:
<?php
$sql="SELECT a.product_id, a.Options_id, b.product_name, b.product_price, b.product_url, d.product_id, d.image_id, e.filename, e.image_id, h.product_id, h.Offer_price
FROM ProductOptions a
JOIN Products b ON a.product_id = b.product_id
JOIN ProductImage d ON d.product_id = b.product_id
JOIN image e ON e.image_id = d.image_id
JOIN ProductOffer h ON h.product_id = b.product_id
GROUP BY product_name
ORDER BY product_name DESC";
$result = mysql_query($sql);
if (!$result)
{
echo "An error occurred ".mysql_error();
exit;
}
echo "<table border=1>\n<tr><th><th></th></th><th bgcolor=\"#DFE8EC\">Name</th><th bgcolor=\"#DFE8EC\">Price OFFER!</th><th bgcolor=\"#DFE8EC\"></th><th>Product URL</th></tr>\n";
while ($line = mysql_fetch_array($result)) {
$name = $line["product_name"];
$url=$line["product_url"];
$image=$line["filename"];
$offer=$line["Offer_price"];
echo "<tr><td></td><td><img src=\"http://www.ehustudent.co.uk/cis21318867/cis3122/Tiersco%20Pro%20BodyBuilding/storeadmin/images/$image\" border=0></td><td bgcolor=\"#DFE8EC\">$name</td><td bgcolor=\"#DFE8EC\">£$offer</td><td bgcolor=\"#DFE8EC\"></td><td><a href= $url > More Info </a></td></tr>\n";
}
echo "</table>\n";
?>
当新的报价插入数据库时,while 循环肯定会继续更新