现在我需要显示产品的图片,用id号命名。不是这样工作的:用php显示图片
$cat_list .= "Product ID: $id - <strong>$product_name</strong> - <img src=inventory_images/'$id'.jpg"> <br />";
我该怎么做呢? 它不工作,这样,整个代码是这样的:在$ cat_list串
<?php
$cat_list="";
$cat=$_GET['cat'];
$cat_sql="SELECT * FROM products,prod_cat,categories WHERE categories.id=prod_cat.cat_id AND products.id=prod_cat.prod_id AND categories.id=$cat";
$cat_query=mysql_query($cat_sql) or die(mysql_error());
$productCount = mysql_num_rows($cat_query); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($cat_query)){
$id = $row["id"];
$product_name = $row["product_name"];
$cat_list .= "Product ID: $id - <strong>$product_name</strong> - <br />";
}
}
?>
那么在图像应该是什么网址在存在吗? – leftclickben 2013-02-12 08:40:04
inventory_images/$ id.jpg – user2003332 2013-02-12 08:41:43
我看到的第一个字符串中的多个“,它运行没有错误尝试'回声 '... - '$ PRODUCT_NAME' -
';。' – 2013-02-12 08:42:58