![](/img/trans.png)
[英]show all images in my products page from a selected category when a category link is selected- php Mysql
[英]how to show images in php page from link saved in DB
因此,如果您觉得问题重复了,我已经尝试了其他解决方案但没有奏效。我将图像链接存储在数据库(phpMyAdmin)中作为字符串。我想将图像作为数据库表第二列的一部分加载使用链接。
<table style="width:100%" id="to1">
<tr>
<th>ID</th>
<th>Featured Image</th>
<th>Title</th>
<th>Brand Name</th>
<th>Price</th>
<th>Quantity</th>
<th>Shipping Cost</th>
<th>Delivery Time </th>
<th>Delivery Distance</th>
</tr>
<?php
$conn = mysqli_connect("localhost","root", "", "products");
if ($conn-> connect_error){
die("Connection Failed: ". $conn-> connect_error);
}
$sql = "SELECT id,featured_image,title,brand_name,price,quantity,shipping_cost,delivery_time,delivery_distance from products";
$result = $conn-> query($sql);
if ($result-> num_rows > 0){
while ($row = $result-> fetch_assoc()){
$val = $row["featured_image"];
echo "<tr><td>".$row["id"] ."</td><td>". '<img src='<?= **HERE** ?>' alt="">' ."</td><td>".$row["title"] ."</td><td>".$row["brand_name"] ."</td><td>".$row["price"] ."</td><td>".$row["quantity"] ."</td><td>".$row["shipping_cost"] ."</td><td>".$row["delivery_time"] ."</td><td>".$row["delivery_distance"] ."</td></tr>";
}
echo "</table>";
}
else{
echo "0 tables";
}
$conn-> close();
?>
我已经把这个地方显示为这里。请提出一些建议,以便我可以在表格中显示图像而不是链接。 这就是我想要的样子。
我想,你有报价问题:
更新:
echo "<tr><td>".$row["id"] ."</td><td><img src='".$row["featured_image"]."' alt=''></td><td>".$row["title"]."</td><td>".$row["brand_name"]."</td><td>".$row["price"]."</td><td>".$row["quantity"]."</td><td>".$row["shipping_cost"]."</td><td>".$row["delivery_time"]."</td><td>".$row["delivery_distance"] ."</td></tr>";
echo "
<tr>
<td>.$row["id"].</td>
<td>.<img src='$row["featured_image"]' alt="">.</td>
<td>.$row["title"].</td>
<td>.$row["brand_name"].</td>
<td>.$row["price"].</td>
<td>.$row["quantity"].</td>
<td>.$row["shipping_cost"].</td>
<td>.$row["delivery_time"].</td>
<td>.$row["delivery_distance"].</td>
</tr>"
尝试这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.