菜鸟学习中遇到问题,高分来请教各位高手,即时结贴给分。

zftnt 2004-08-05 09:17:30
我图片路径已经上传到Access数据库里,现在我想显示图片预览图,如何才能做到从数据库读出图片路径记录,在一个表格里分三行三列的显示9张小图片,点击小图能够显示大图,这段代码该怎么写?
...全文
230 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
wgb219 2004-08-05
  • 打赏
  • 举报
回复
if Rs.eof or Rs.bof then
response.Write"<td width=149 align=right>暂时没有相关信息...</td>"
else
i=1
do while not Rs.eof
i=i+1
image=Rs("imageurl")
%>
<td height="100">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><A href="<%=image%>" target="_blank"><img src="<%=image%>" width="80" height="80" border="0"></a></td>
</tr>
</table></td>
<%
if i>3 then
response.write "</tr><tr align='center'>"
i=1
end if
Rs.Movenext
loop
end if
set rs=nothing
end if
%>
wgb219 2004-08-05
  • 打赏
  • 举报
回复
if Rs.eof or Rs.bof then
response.Write"<td width=149 align=right>暂时没有相关信息...</td>"
else
i=1
do while not Rs.eof
i=i+1
image=appPicPath&Rs("Pimagename")
%>
<td height="100">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><A href="<%=image%>" target="_blank"><img src="<%=image%>" width="80" height="80" border="0"></a></td>
</tr>
</table></td>
<%
if i>3 then
response.write "</tr><tr align='center'>"
i=1
end if
Rs.Movenext
loop
end if
set rs=nothing
end if
%>
dout 2004-08-05
  • 打赏
  • 举报
回复
sorry,错了
应该是
<%
sql="select top 9 * from info order id date desc"
rs.open sql,conn,1,1
do while not j=3
i=0
if not rs.eof then
response.write"<tr>"
do while not rs.eof
response.write"<td width=""95"" align=""center"" valign=""top"" nowrap>"
response.write"<a target=""_blank"" href="""&rs("pic")&""">"
response.write"<img src="""&rs("pic")&""" border=""0"" width=""95"" height=""75"">
response.write "</td>"
i=i+1
if i>=3 then exit do
rs.movenext
loop
response.write"</tr>"
end if
j=j+1
' response.write(j)
loop
rs.close
%>
dout 2004-08-05
  • 打赏
  • 举报
回复
搞定
你用你的相应变量替换下面代码的变量就可以了
效果图在http://xike.wegame.com/xg.jpg
<%
sql="select top 9 * from info order id date desc"
rs.open sql,conn,1,1
do while not j=3
i=0
if not rs.eof then
response.write"<tr>"
do while not rs.eof
response.write"<td width=""95"" align=""center"" valign=""top"" nowrap>"
response.write"<a target=""_blank"" href=""info/"&rs("id")&".htm"">"
response.write"<img alt="""&rs("title")&" "&rs("se")&""" src="""&rs("pic")&""" border=""0"" width=""95"" height=""75"">"
response.write "</td>"
i=i+1
if i>=3 then exit do
rs.movenext
loop
response.write"</tr>"
end if
j=j+1
' response.write(j)
loop
rs.close
%>
zftnt 2004-08-05
  • 打赏
  • 举报
回复
晕了晕了,西科时空,我用for循环不知道写那个位置,具体点教我要怎么循环这个,谢谢啊
zftnt 2004-08-05
  • 打赏
  • 举报
回复
多谢西科时空,我马上测试一下,搞不定我再回来,呵呵
zftnt 2004-08-05
  • 打赏
  • 举报
回复
guoweidong(※『孤独~寂)朋友,能否把完整代码贴下,我看的不太明白,循环是在哪里,分页 我看到了,请多指点我一下啊
顺子 2004-08-05
  • 打赏
  • 举报
回复
去找點例子看吧
dout 2004-08-05
  • 打赏
  • 举报
回复
第一个文件
conn.asp
'实现数据库联接
'以下是代码
<%
dim db,rs,conn,Connstr

db="db/db.mdb" '你的数据库路径和名字
Set Conn=Server.CreateObject("ADODB.CONNECTION")
ConnStr="DBQ="+Server.Mappath(db)+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Conn.Open ConnStr
%>

第二个文件
pic.asp
'读你的图片的地址
'只有读取数据库部分
<%
i=0
sql="select top 9 * from info where pic<>'' order by id desc" '取出前9张图片
rs.open sql,conn,1,1

'你用for循环3次下面的代码就是3行3列的了
if not rs.eof then
do while not rs.eof
response.write"<td width=""95"" align=""center"" valign=""top"" nowrap>"
response.write"<a target=""_blank"" href="""&rs("pic")&""">"
response.write"<img src="""&rs("pic")&""" border=""0"" width=""95"" height=""75"">
response.write"</td>"
i=i+1
if i>=3 then exit do
rs.movenext
loop
end if
rs.close
%>
搞不定再说
古侠 2004-08-05
  • 打赏
  • 举报
回复
学习,以前只会把图片上传,查看,呵呵
guoweidong 2004-08-05
  • 打赏
  • 举报
回复
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th align="right" scope="col"><img src="images/wsdg-1.gif" width="593" height="150"></th>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th height="2" bgcolor="#9B9B00" scope="col"></th>
</tr>
</table>
<table width="100%" border="0">
<%
dim i,intPage,page,pre,last,filepath,IsShow
set rs=server.createobject("adodb.recordset")
if request("newnames")<>"" then
sql = "select * from com_info where name like '%"&request("newnames")&"%' order by ID desc"
else
sql="select * from com_info "&searchStr&merchandise_mc&"order by ID desc"
end if
rs.open sql,conn,1,3
rs.PageSize = 9 '这里设定每页显示的记录数
pre = true
last = true
page = trim(Request.QueryString("page"))
if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then exit for
if (counts mod 3) =0 then
%>
<tr>
<%
end if
counts=counts+1
%>
<td>
<table width="100%" border="0">
<tr>
<td width="33%">
<div align="center" class="style2">        
<div align="center"><img src="images/point.gif" width="10" height="10"><strong><%=rs("merchandise_pp")%></strong><br>
<%=rs("name")%>
</div>
</div></td>
</tr>
<tr>
<td width="33%">
<div align="center"><a href="wsdg_view.asp?ID=<%=rs("ID")%>"><img src="./<%=rs("merchandise_tplj")%>" width="150" height="150" border="0"></a>
</div></td></tr>
<tr>
<td width="33%">
<div align="center" class="style2">价格:<%=rs("merchandise_xj")%>元
<%
if rs("merchandise_yj")<>"" then
%>
<span class="d9yellow" >(原价:
<%=rs("merchandise_yj")%>元
)
<%
end if
%>
</span> </div></td>
</tr>
</table>
<%
rs.movenext
next
%>
</table>
<table width="99%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
<tr>
<%if rs.pagecount > 0 then%>
<td width="13%" align="left"><span class="style2">当前页<%=intpage%>/<%=rs.PageCount%></span></td>
<%else%>
<td width="41%" align="left"><span class="style2">当前页0/0</span></td>
<%end if%>
<td width="46%" align="right"> <span class="style2"><a href="wsdg.asp?merchandise_flid=<%=merchandise_flid%>&names=<%=names%>&page=1">首页</a>|
<%if pre then%>
<a href="wsdg.asp?merchandise_flid=<%=merchandise_flid%>&names=<%=names%>&page=<%=intpage -1%>">上页</a>|
<%end if%>
<%if last then%>
<a href="wsdg.asp?merchandise_flid=<%=merchandise_flid%>&names=<%=names%>&page=<%=intpage +1%>">下页</a> |
<%end if%>
<a href="wsdg.asp?merchandise_flid=<%=merchandise_flid%>&names=<%=names%>&page=<%=rs.PageCount%>">尾页</a>|转到第
<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to rs.PageCount
if i = intpage then%>
<option value="wsdg.asp?merchandise_flid=<%=merchandise_flid%>&names=<%=names%>&page=<%=i%>" selected><%=i%></option>
<%else%>
<option value="wsdg.asp?merchandise_flid=<%=merchandise_flid%>&names=<%=names%>&page=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>
页</font>
</span></td>
</tr>
</table>
</td>
life360 2004-08-05
  • 打赏
  • 举报
回复
显示图片

<img src="<%=rs("路径")%>" width="宽度" height="高度">
guoweidong 2004-08-05
  • 打赏
  • 举报
回复
http://www.jsycjw.gov.cn/yczsc/wsdg.asp
zftnt 2004-08-05
  • 打赏
  • 举报
回复
循环应该怎么写,教我点技巧以及应该注意的地方
BlueDestiny 2004-08-05
  • 打赏
  • 举报
回复
同意楼上。
<a href="<%=rs("image_url")%>" target="_blank">
<img src="<%=rs("image_url")%>" alt="" width="100%" height="100%" border="0">
</a>
预览图就是这里。
afdfgg 2004-08-05
  • 打赏
  • 举报
回复
先从数据库读出链接字段,下面是一个单元格的内容,你可以参考一下,然后用一个循环实现多格
<td width="146" height="152" valign="top"><a href="<%=rs("image_url")%>" target="_blank"><img src="<%=rs("image_url")%>" alt="" width="100%" height="100%" border="0"></a></td>
ymeik 2004-08-05
  • 打赏
  • 举报
回复
xuexi
DARKNESSFALL 2004-08-05
  • 打赏
  • 举报
回复
img src="<%=rs("路径")%>"
zftnt 2004-08-05
  • 打赏
  • 举报
回复
哈哈,我人缘好啊,大家共同学习共同进步啊
qhyan23 2004-08-05
  • 打赏
  • 举报
回复
楼主你很厉害呀!有这么多的高手帮你.
我也学到了很多,谢了.
加载更多回复(8)

28,391

社区成员

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

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