asp上下一页
<%
'定义一个nextrs函数来找出下一篇的ID
function nrs
nrs=server.CreateObject("adodb.recordset")
sql="select * from articles where id>"&a1&" order by id"
set nrs=conn.execute(sql)
if nrs.eof then
response.Write"下一篇:这是本分类下的最后一篇文章"
else
a2=nrs("id")
response.Write"下一篇:<a href='article.asp?id="&a2&"'>"&nextrsd("title")&"</a>"
end if
end function
'定义一个backrs函数来找出上一篇的ID
function brs
brs=server.CreateObject("adodb.recordset")
sql="select top 1 * from articles where id<"&a1&" order by id desc"
set brs=conn.execute(sql)
if brs.eof then
response.Write "上一篇:这是本分类下的第一篇文章"
else
a0=brs("id")
response.Write "上一篇:<a href='article.asp?id="&a0&"'>"&brs("title")&"</a>"
end if
end function
'取得传递过来的文章ID
set rs=conn.execute(sql)
sql="select * from articles where id="&request("id")
a1=rs("id")
%>