图片在文件夹中,图片的id   名称   上传时间写在数据库中,要怎么写代码才能在网页上显示图片??、

解决方案 »

  1.   

    图片的路径是确定的么?
    先查出图片的名称,然后显示就是了。<img src='./uploads/<?php echo $filename?>' />
      

  2.   

    上传图片时要把图片的url写至一个字段。显示时用id来取。
      

  3.   

    比如你的图片文件是保存在upload文件夹那里,文件名称保存在数据表id字段中<?php
    echo "<img src='upload/".$row['id'].".gif'>";//$row['img']取数据表id,.gif是直接加上图片后缀
    echo "<img src='upload/".$row['id'];//有的把后缀也直接附在id里面了,所以改成这种写法,你自己看一下是那种
    ?>
      

  4.   


    <?php 
       $query="select tpmc from tb_tpsc   order by id  desc "; 
            
    $result=mysql_query($query);
    echo "<img src='./uploading/<?php echo $tpmc?>' /> "
    ?> 
    这样写对吗?它显示出来的是一个×
      

  5.   


    这样肯定是错误的,mysql_query()返回的不是结果集。要再执行一次mysql_fetch_array();
    比如你要显示
    <?php 
      $query="select tpmc from tb_tpsc order by id desc"; 
       
      $res = mysql_query($query);
      while($result = mysql_fetch_array($res)){
        echo " <img src='uploads/<?php echo $filename?>' />" ;
      }?>  
      

  6.   

    这个echo " <img src='uploads/<?php echo $filename?>' />" ;
    中的$filename是指哪个文件名?需不需要改
      

  7.   


    换成你保存图片的响应名字   $result['tpmc'];还要注意目录正确。
      

  8.   

    <?php 
      $query="select tpmc from tb_tpsc order by id desc"; 
       
      $res = mysql_query($query);
      while($result = mysql_fetch_array($res)){
        echo " <img src='uploading/<?php echo $filename?>' />" ;
      }?>  
    我用这段代码  为什么显示的全部是×,图片显示不出来 
      

  9.   

    图片目录是D:\AppServ\www\xy\uploadimg
    显示图片的网页代码:
    <?php session_start();include("conn/conn.php");?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><body>
    <?php 
      $query="select tpmc from tb_tpsc order by id desc"; 
       
      $res = mysql_query($query);
      while($result = mysql_fetch_array($res)){
        echo " <img src='uploading/<?php echo $result['tpmc']?>' />" ;
      }?>  </body>
    </html>
      

  10.   

    我增加了一个字段  url来存储路径,要怎样才能把路径写入数据库???