我已将图像路径存储在数据库和项目文件夹中的图像。现在我正试图在我的HTML模板中查看与他们的产品的所有图像。我写了下面的代码,并给出了输出中的空白图像框,当我在新选项卡中打开该图像框时,它会打开以下URL。如何显示存储在数据库中的路径的图像?
http://localhost/cms/1
请告诉我在'img src'标记中引用图像的方式。
include 'connect.php';
$image_query = "select * from product_images";
$image_query_run = mysql_query($image_query);
$image_query_fetch = mysql_fetch_array($image_query_run);
if (!$query=mysql_query ("select product_id,name from products")) {
echo mysql_error();
} else {
while ($query_array = mysql_fetch_array($query)) {
echo '</br><pre>';
$product_id = $query_array['product_id'];
echo "<a href='single_product.php?product_id=$product_id' >";
print_r ($query_array['name']);
echo "</a>";
echo "<img src=". $image_query_fetch
['images'] ." alt=\"\" />";
echo '</pre>';
}
}
} else {
echo "You need to Log in to visit this Page";
}
mysql_被弃用功能的PHP 5.5的.0,使用mysqli_或PDO。** REF:http://www.php.net/manual/en/function .mysql-fetch-array.php ** – dreamweiver