您好我在尝试执行一个代码,其中将根据同一列的数据库中包含的行数在TABLE列中提取图像。在这里,我使用列名作为名称来获取图像。 因为可以有许多相同类型的列,所以我使用循环从同一列的数据库中获取图像。 这是我的代码
<?php
$connect=new mysqli("localhost","root","");
mysqli_select_db($connect,'go-web');
$query=mysqli_query($connect,"SELECT * from product WHERE name LIKE 'Groc%' ");
$result=mysqli_num_rows($query);
while($result!=0){
echo '
<td style="height:200px;width:20%;">
<img src="<?php
$query1=mysqli_query($connect,"SELECT image from product where name like "Groc%"");
$result1=mysqli_query($connect,$query1);
$row=mysqli_fetch_assoc($result1);
echo $row["image"];
?>" width="150px" height="150px" /><center><figcaption>Price:</figcaption></center><br>
<center><figcaption>Stock:</figcaption></center></td>';
$result--;
}
?>
任何帮助?
答案 0 :(得分:0)
这应该有效
<?php
$connect=new mysqli("localhost","root","");
mysqli_select_db($connect,'database')
$query=mysqli_query($connect,"SELECT * FROM table_name where name='$name'");
echo "<table>";
while($row=mysqli_fetch_array($query)){
echo '<tr><td style="height=100px"><a href=""><img src="'.$row['image'].'" width="150px" height="150px" /></a></td></tr>';
}
echo "</table>";
?>