繁体   English   中英

无法显示数据库中的其他图像

[英]Unable to display different images from the database

我正在开发一个电子商务网站,但无法在主页上显示数据库中的其他产品图像。 下面的代码仅显示所有产品的一张图像,而假定它们是不同的图像(通过后端上传)。 产品名称,价格和类别显示良好,但图像未显示。 我想知道为什么。

这是我的代码

<?php
// connect to the database
include('variables.php');

// get the records from the database
$sql = "SELECT * FROM products ORDER BY id ASC LIMIT 0, 6";
$result = $connection->query($sql);
$getImage=mysqli_query($connection, "SELECT * FROM products ") or die("Could not retrieve image: " .mysqli_error($connection));
$path=mysqli_fetch_assoc($getImage) or die("Could not fetch array : " .mysqli_error($connection));
if ($result) 
{
    // output data of each row                    
    while($row = $result->fetch_assoc()) 
    {  
        echo '<li class="span3"><div class="product-box">';

        echo'<span class="sale_tag"></span>';

        echo'<p><a href="product_detail.php?id=' . $row["id"] . '"><img src="../backend/images/'.$path['productimage'].'" width="250" height="120"></a></p>';           
        echo  $row["name"]. "</a><br>";
        echo'<a href="products.html" class="category">' . $row["categoryname"]. '</a>';
        echo'<p class="price">KSh:' . $row["price"].'</p>';
        echo'</div></li>';
    }
}
?>

请协助

在while循环中将$ path更改为$ row

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM