[英]Why is my images not appearing, when trying to get them from database
Hiya I am getting information from my database to present onto the webpage, everything is correct with connection as the information is present on the page. Hiya我正在从数据库中获取信息以呈现在网页上,因为信息显示在页面上,所以一切都正确。
But when it comes to the pictures they come up with a little box of where they are meant to be. 但是,当涉及到图片时,他们会拿出一个小盒子,说明它们的原意。 Heres the code I have:
这是我的代码:
<?php
error_reporting(0);
require './db/connect.php';
include './includes/header.php';
?>
<h2>Production</h2>
<?php
if($result = $connection->query("SELECT * FROM Production")){
if($count = $result->num_rows){
$Image = $rows['Image'];
while($row = $result->fetch_object()){
echo '<pre>'.'<img class="productionimages" src="path/'.$Image.'" />',' '
,$row->ProductionName,' ',$row->ProductionType, '</pre>';
}
$result->free();
}
}
echo $result;
include './includes/footer.php';
?>
Heres a picture below of what appears on the screen. 以下是屏幕上显示的图片。
You need to set $Image within the while loop and $rows['Image'] should be $row->Image, like so. 您需要在while循环中设置$ Image,并且$ rows ['Image']应该是$ row-> Image,就像这样。
<?php
if($result = $connection->query("SELECT * FROM Production")){
if($count = $result->num_rows){
while($row = $result->fetch_object()){
$Image = $row->Image;
echo '<pre>'.'<img class="productionimages" src="path/'.$Image.'" />',' '
,$row->ProductionName,' ',$row->ProductionType, '</pre>';
}
$result->free();
}
}
echo $result;
include './includes/footer.php';
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.