网站建设之ASP上一篇下一篇代码
ASP新闻文章或者产品中的上一篇(个)和下一篇(个)的程序代码:
<%
id = TRIM(request("id"))
sqlPrev = "select top 1 * from news where id<" &id &" order by id desc"'上一篇(个)读取
sqlNext = "select top 1 * from news where id>" &id &" order by id"'下一篇(个)读取
SET rsPrev = conn.EXECUTE(sqlPrev)
SET rsNext = conn.EXECUTE(sqlNext)
Response.WRITE "<TABLE WIDTH=""800"" BORDER=""0"" ALIGN=""CENTER"" CELLPADDING=""0"" CELLSPACING=""0"">"&vbCrLf
IF rsPrev.EOF THEN
Response.WRITE "<TR><TD HEIGHT=""20"" align=left>上一篇文章:没有了</TD></TR>"&vbCrLf
ELSE
Response.WRITE "<TR><TD HEIGHT=""20"" align=left>上一篇文章:<a href=""news.asp?id="&rsPrev("id")&""">"&rsPrev("Title")&"</a></TD></TR>"&vbCrLf
END IF
IF rsNext.EOF THEN
Response.WRITE "<TR><TD HEIGHT=""20""align=left>下一篇文章:没有了</TD></TR>"&vbCrLf
ELSE
Response.WRITE "<TR><TD HEIGHT=""20""align=left>下一篇文章:<a href=""news.asp?id="&rsNext("id")&""">"&rsNext("Title")&"</a></TD></TR>"&vbCrLf
END IF
Response.WRITE "</TABLE>"&vbCrLf
rsPrev.CLOSE
SET rsPrev = NOTHING
rsNext.CLOSE
SET rsNext = NOTHING
%>
对产品的上一个产品,下一个产品同样适用。