图片在文件夹中,图片的id 名称 上传时间写在数据库中,要怎么写代码才能在网页上显示图片??、 图片在文件夹中,图片的id 名称 上传时间写在数据库中,要怎么写代码才能在网页上显示图片??、 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 图片的路径是确定的么?先查出图片的名称,然后显示就是了。<img src='./uploads/<?php echo $filename?>' /> 上传图片时要把图片的url写至一个字段。显示时用id来取。 比如你的图片文件是保存在upload文件夹那里,文件名称保存在数据表id字段中<?phpecho "<img src='upload/".$row['id'].".gif'>";//$row['img']取数据表id,.gif是直接加上图片后缀echo "<img src='upload/".$row['id'];//有的把后缀也直接附在id里面了,所以改成这种写法,你自己看一下是那种?> <?php $query="select tpmc from tb_tpsc order by id desc "; $result=mysql_query($query); echo "<img src='./uploading/<?php echo $tpmc?>' /> "?> 这样写对吗?它显示出来的是一个× 这样肯定是错误的,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?>' />" ; }?> 这个echo " <img src='uploads/<?php echo $filename?>' />" ;中的$filename是指哪个文件名?需不需要改 换成你保存图片的响应名字 $result['tpmc'];还要注意目录正确。 <?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?>' />" ; }?> 我用这段代码 为什么显示的全部是×,图片显示不出来 图片目录是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> 我增加了一个字段 url来存储路径,要怎样才能把路径写入数据库??? 求批量导入图片去除外链方法 php 文件中有一段排序功能,如何应用? 求解:并发执行远程telnet到多个服务器查询硬盘,这个怎样实现 求路过的高手,帮小弟解决一个php取用API的问题呀! 请高手指教字符串有关问题 PHP输出XML在IE7中显示的奇怪问题,求解 一个php动态视频转换问题 这是什么怪问题???? 请教各位大侠:怎样在Windows XP系统下安装PHP? 难道歧视中国人?Zend studio 不支持中文?我的汉字为什么都是框框? 页面跳转问题 上传到文件夹里的图片怎么显示在网页上啊?
先查出图片的名称,然后显示就是了。<img src='./uploads/<?php echo $filename?>' />
echo "<img src='upload/".$row['id'].".gif'>";//$row['img']取数据表id,.gif是直接加上图片后缀
echo "<img src='upload/".$row['id'];//有的把后缀也直接附在id里面了,所以改成这种写法,你自己看一下是那种
?>
<?php
$query="select tpmc from tb_tpsc order by id desc ";
$result=mysql_query($query);
echo "<img src='./uploading/<?php echo $tpmc?>' /> "
?>
这样写对吗?它显示出来的是一个×
这样肯定是错误的,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?>' />" ;
}?>
中的$filename是指哪个文件名?需不需要改
换成你保存图片的响应名字 $result['tpmc'];还要注意目录正确。
$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?>' />" ;
}?>
我用这段代码 为什么显示的全部是×,图片显示不出来
显示图片的网页代码:
<?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>