我想從數據庫中檢索這些圖像。如何在html中從數據庫檢索多個圖像<img>標籤
<html>
<body>
<?php
$servername="localhost";
$username="root";
$pass="";
$db="db";
$conn=new mysqli($servername,$username,$pass,$db);
$result=$conn->query("select * from image");
while($row_brand=mysqli_fetch_array($result))
{
$brand_image=$row_brand['image'];
?>
<div class="div1">
<?php
echo "<img src='uploads/$brand_image' />";
echo <img src="image.php?id=<? echo $image['id'];?>" />
}
?>
</div>
</body>
</html>
我使用此代碼來獲取所有圖像。
但我想在圖像<img>
標記中獲取圖像。
所以請幫助我,我如何使用<img>
標籤在html文件中獲取所有這些圖像。
'$ image ['id']'這是從哪裏來的? – madalinivascu
$ row_brand ['id']; insign of $ image ['id']; – JYoThI
1.您正在覆蓋循環中的'$ brand_image'變量,2.您在顯示圖像時沒有使用循環,3.嘗試顯示ID時嘗試訪問不存在的變量。 – jeroen