gpt4 book ai didi

php - 在相同列名的表中循环获取图像

转载 作者:行者123 更新时间:2023-11-30 22:15:53 25 4
gpt4 key购买 nike

您好,我正在尝试执行一个代码,其中将根据同一列的数据库中包含的行数在 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--;
}
?>

有什么帮助吗?

最佳答案

这应该可行

 <?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>";

?>

关于php - 在相同列名的表中循环获取图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38310375/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com