Php 从SQL连接图像
每次我尝试加载下面的页面时,图像都不会显示。我在SQL数据库中有图像名称,并且图像文件夹与index.php路径相同Php 从SQL连接图像,php,html,sql,Php,Html,Sql,每次我尝试加载下面的页面时,图像都不会显示。我在SQL数据库中有图像名称,并且图像文件夹与index.php路径相同 <div class="container-fluid"> <div class="col-md-12"> <div class="row"> <div class="col-md-6&qu
<div class="container-fluid">
<div class="col-md-12">
<div class="row">
<div class="col-md-6">
<h2 class="text-center">Products</h2>
<?php
$query = "SELECT * FROM product";
$result = mysqli_query($connect,$query);
while ($row = mysqli_fetch_array($result)) {?>
<form method="get" action="index.php?id=<?= $row['id'] ?>">
<img src="img/<?= $row['image'] ?>" style='height: 150px;'>
<h2><?= $row['name']; ?></h2>
<h2><?= $row['price']; ?></h2>
</form>
<?php }
?>
</div>
<div class="col-md-6">
<h2 class="text-center">Shopping Cart</h2>
</div>
</div>
</div>
</div>
</body>
</html>
产品
我在我的电脑上尝试了这个代码,图像显示得非常完美
也许,您忘记放置连接查询
<div class="container-fluid">
<div class="col-md-12">
<div class="row">
<div class="col-md-6">
<h2 class="text-center">Products</h2>
<?php
$connect = mysqli_connect('localhost','root','','test');
$query = "SELECT * FROM product";
$result = mysqli_query($connect,$query);
while ($row = mysqli_fetch_array($result)) {?>
<form method="get" action="index.php?id=<?= $row['id'] ?>">
<img src="img/<?= $row['image'] ?>" style='height: 150px;'>
<h2><?= $row['name']; ?></h2>
<h2><?= $row['price']; ?></h2>
</form>
<?php }
?>
</div>
<div class="col-md-6">
<h2 class="text-center">Shopping Cart</h2>
</div>
</div>
</div>
</div>
产品
有什么错误吗?您是否进行过var_转储($row);看看数据是否存在?html是什么样子的?