请大家帮个忙看一下错在哪里!.下一张可以翻.但是上一张就不行,一点上一张就跳到第一张去了.并且翻到最后一张时居然一下跳到第一张来了,我晕~~汗~~
<%
dim rs1,rs2,rs3,nid,rid,imgname,sql,sql1,sql2
imgname=request("imgname")
set rs=Server.CreateObject("adodb.recordset")
if request("nid")<>"" then
nid=request("nid")
sql="select * from img where id="&nid&""
else
if imgname="" then
sql="select top 1 id,imgname from img order by data desc"
else
sql="select * from img where imgname='"&imgname&"'"
end if
end if
rs.open sql,conn,2,3
id=rs("id")
%>
<td><div align="left"><img src="admin/adminpic_up/images/<%=rs("imgname")%>" width="344" height="229" /></div></td>
</tr>
<tr>
<td><div align="center"><% set rs1=server.CreateObject("adodb.recordset")
sql1="select top 1 id,imgname from img where id>"&id&" order by id desc"
rs1.open sql1,conn,2,3
if rs1.eof and rs1.bof then
response.Write"<font style='font-size:12px; color:#ffffff;'>上一张 </font>"
else
response.write"<a href=""pic_show.asp?nid="&rs1(0)&""" style='font-size:12px; color:#ffff00;'>上一张</a> " end if
set rs1=nothing
set rs2=server.createobject("adodb.recordset")
sql2="select top 1 id,imgname from img where id<"&id&" order by id desc"
rs2.open sql2,conn,2,3
if rs2.eof and rs2.bof then
response.write"<font style='font-size:12px; color:#ffffff;'>此是最后一张</font>"
else
response.write"<a href=""pic_show.asp?nid="&rs2(0)&""" style='font-size:12px; color:#ffff00;'> 下一张</a> " end if
rs.close
set rs2=nothing
%> </div></td>
</tr>