douqin6785 2012-02-01 18:58
浏览 24

图像现在显示从数据库调用时

SOLVED!

so ive created an image upload page which saves the image to a folder and sends the file name to the DB, ive checked to see if they are actually being added to the DB and folder which they are, but when i call the data to another page to display the images i get broken images.

below is my code to call the images, its some code ive scraped together from various tutorials as they gave me the same problem as im having now.

UPDATE: ive managed to get the images showing but now im faced with being shown the same image for each row of data called, the id and img_name and right for each row but the image is always the same as the first listed.

UPDATED CODE:

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

//save the name of image in table
$query = mysql_query("select * from tbl_img") or die(mysql_error());

//retrieve all image from database and store them in a variable
while ($row = mysql_fetch_assoc($query))
{
    $img_name = $row['img'];
}
?>



<?php

include ('connect.php');

$img_id = mysql_query("SELECT * FROM tbl_img");

while ($row = mysql_fetch_assoc($img_id))
{

$id = $row['img_id'];

echo "
$id<br>
$img_name<br>
<img src='http://localhost/testarea/include/site_images/$img_name' />
";

echo "<br><br><br></p>
";

}

?>
  • 写回答

2条回答 默认 最新

  • dtz30833 2012-02-01 19:33
    关注

    If you start the path of image with / you mean an absolute path where / is the DocumentRoot folder (or the directory of virtualhost)

    With src ="includes/xxx/image.png" you mean that includes is in the same folder with the php script. If it is not you can use relative path like

    src="../includes/xxx/image.png" for example

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图