发一个可以显示上一篇下一篇文章的代码
发一个可以显示上一篇下一篇文章的代码,上一篇就是根据当前ID,数据库里ID大于当前ID的即为上一篇,下一篇也一样,这样即使ID不是连续的也可以。以下是代码,如果有错误,欢迎指出。<%
id = request("id")
function up(id)
dim rs1,sql1
sql1="select * from product where id > "&id&" order by id asc"
set rs1 = conn.execute(sql1)
if rs1.eof then
response.write"<font size='2'>没有了</font>"
else
up_id = rs1("id")
response.write"<a href='showproduct.asp?id="&up_id&"' style='color:#ff0066;text-decoration:none'>"&rs1("title")&"</a>"
end if
rs1.close
set rs1 = nothing
end function
function down(id)
dim rs2,sql2
sql2="select * from product where id < "&id&" order by id DESC"
set rs2 = conn.execute(sql2)
if rs2.eof then
response.write"<font size='2'>没有了</font>"
else
down_id = rs2("id")
response.write"<a href='showproduct.asp?id="&down_id&"' style='color:#ff0066;text-decoration:none'>"&rs2("title")&"</a>"
end if
rs2.close
set rs2 = nothing
end function
%>