Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从数据库中保存的链接在php页面中显示图像_Php_Mysql_Image - Fatal编程技术网

如何从数据库中保存的链接在php页面中显示图像

如何从数据库中保存的链接在php页面中显示图像,php,mysql,image,Php,Mysql,Image,因此,如果您觉得这个问题重复出现,我尝试了其他解决方案,但没有效果。我将图像链接作为字符串存储在数据库(phpMyAdmin)中。我希望使用链接从DB将图像作为表的第二列的一部分加载 <table style="width:100%" id="to1"> <tr> <th>ID</th> <th>Featured Image</th> <th>Title</th>

因此,如果您觉得这个问题重复出现,我尝试了其他解决方案,但没有效果。我将图像链接作为字符串存储在数据库(phpMyAdmin)中。我希望使用链接从DB将图像作为表的第二列的一部分加载

<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.$row[“id”]。$row[“title”]。$row[“brand_name”]。$row[“price”]。$row[“quantity”]。$row[“shipping_cost”]。$row[“delivery_time”]。$row[“delivery_distance”];
echo”
.$行[“id”]。
..
.$行[“标题”]。
.$row[“品牌名称”]。
.$行[“价格”]。
.$行[“数量”]。
.$行[“运费”]。
.$row[“交货时间”]。
.$行[“交货距离”]。
"

试试这个

“我尝试过其他解决方案,但不起作用”在你上面的帖子中,我看不到任何证据<代码>
没有告诉我们您尝试了什么,也没有告诉我们结果是什么。什么是“存储为字符串的图像”?链接?Uuencoding?作为提示,您可以编写
SELECT*from products
,而不是一个接一个地写出它们。@PatrickQ我试过了,只是我删除了它,有些地方使用while循环,有些地方使用while循环,我试了两个答案,只找到2个answers@TheWelshManc我不能这样做,因为表中还有其他列。语法错误,意外的“>”(t_CONSTANT_ENCAPSED_STRING),应为“,”或“;”
    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>"