新手问题,迅速拿分

woods2001 2009-05-03 01:54:36
大家帮我看看这个问题
具体来说: 我在表中保存了图片的相对地址 在需要显示的时候直接查表找到所需要的图片的地址
然后把它显示出来
我的做法是:在后台中添加商品信息的时候 在图片地址信息栏中输入图片地址
然后在后台中商品信息查询中要把图片显示出来
<td width="121" rowspan="6" align="center" valign="top">图片显示<BR>
<img src="Img.asp?id=<%=rs("id")%>&action=商品信息" width="120"

height="60"></td>
其中Ima.asp的代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="include/conn.asp"-->
<!--#include file="checklogin.asp"-->
<%
action=Request.QueryString("action")
Select case action
case "友情链接"
call klink()
case "商品信息"
call goods()
End Select
'子过程
Function klink()
Set rs=Server.CreateObject("ADODB.Recordset")
id=Request.QueryString("id")
sqlstr="select Kpicture from tab_klink where id="&id&""
rs.open sqlstr,conn,1,3
klink="Fklink/"&<%=rs("Kpicture")%>"
rs.close
Set rs=Nothing
End Function
Function goods()
Set rs=Server.CreateObject("ADODB.Recordset")
id=Request.QueryString("id")
sqlstr="select Gpicture from tab_goods where id="&id&""
rs.open sqlstr,conn,1,3
goods="pictures/"&<%=rs("Gpicture")%>"
rs.close
Set rs=Nothing
End Function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>电子商务网站----浏览图片</title>
</head>
<body>
</body>
</html>

帮看看哪出的问题? 谢谢
...全文
75 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
hookee 2009-05-03
  • 打赏
  • 举报
回复
假设rs("Kpicture")的值是"images/xxx.gif"的话
可以简单点 respnse.transfer "images/xxx.gif"
但之前和之后不能输出任何文本以及html标签.
woods2001 2009-05-03
  • 打赏
  • 举报
回复
支持的话
具体怎么做呢 ?
woods2001 2009-05-03
  • 打赏
  • 举报
回复
我用的数据库是sql sever2000支持ADO stream对象吗 ?
hookee 2009-05-03
  • 打赏
  • 举报
回复
用Ado stream对象读取图片文件,然后用response.binaryWrite 输出。
woods2001 2009-05-03
  • 打赏
  • 举报
回复
<img src=" <%=rs("Kpicture")%>" >
我只能在当前页面中获得我要的数据?

我不可以通过调用其他页面 也获得我想要的数据吗
例如 这个方法 <img src="Img.asp?id= <%=rs("id")%>&action=商品信息" width="120"
height="60"> </td>

我不用返回函数的形式
response.write 只能回写2进制数据
那有没有其他的办法或对象来完成我要做的事情呢··?
hookee 2009-05-03
  • 打赏
  • 举报
回复
写法上的问题:
不是函数赋值吗?为何要response.write?
src="Img.asp?id=<%=rs("id")%>&action=商品信息" id=后面必要有空格。
----------------------------------
设计上的问题
如果用 src="img.asp",那么img.asp必须返回二进制数据,不能返回有任何html代码或response.write "xxx"
从你的程序看 rs("Kpicture")保存的只是地址,并不是图片数据。
应该是以下形式
<img src="<%=rs("Kpicture")%>" >
id要从页面本身取得,即
xxx.asp?id=3&action=xxx
xxx.asp中
<%
取字段。。。
%>
<img src="<%=rs("Kpicture")%>" >




woods2001 2009-05-03
  • 打赏
  • 举报
回复
改成这样
response.write "Fklink/"&rs("Kpicture")
response.write "pictures/"&rs("Gpicture")


然后上面那句
<img src="Img.asp?id=<%=rs("id")%>&action=商品信息" width="120"
height="60"></td>
还是有问题啊?
不显示图片
我图片放在picture文件夹里 图片的名称我保存在表中 exp:woods.jpg
hookee 2009-05-03
  • 打赏
  • 举报
回复
<%%>不能嵌套
klink = "Fklink/" & rs("Kpicture")
goods = "pictures/" & rs("Gpicture")

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧