简体   繁体   English

尝试从数据库中获取图像时,为什么我的图像没有出现

[英]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.

相关问题 我数据库中的图像显示为小的小问号 - The images from my database are appearing as little small question marks 当我将所有图像都设置为col-6时,为什么我的图像彼此位于较低的位置? - Why do my images get positioned below each other when I set all of them to col-6? 从数据库中获取图像的两条路径,并将它们循环显示在滑块中 - get two paths of images from database and loop them to display in slider 为什么我在尝试查找特定用户时从 laravel 的数据库中获取 null 值? - why am i getting null value from my database in laravel when trying to find specific user? 尝试下载从我的数据库创建的CSV文件时出现错误 - Get error when trying to download a CSV file created from my database 为什么在按下“提交”后,我的文本字段中的值没有出现在发送的电子邮件中? - Why aren't my values from my text fields appearing in the email sent when submit is pressed? 我正在尝试将一些数据输入数据库。 它创建新表,但不填充它们 - I'm trying to get some data into my database. It creates the new tables but doesn't fill them 当我将它们保存为.HTML文件时,我的PrettyPhoto图像会变形。 - My PrettyPhoto images get distorted when I save them as an .HTML File 当我尝试获取用户 IP 时出现奇怪的代码 - strange code appearing when i am trying to get user IP 将答案插入数据库时​​为什么会重复答案? - Why is it duplicating answers when inserting them into database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM