網(wǎng)站建設(shè)之ASP上一篇下一篇代碼
ASP新聞文章或者產(chǎn)品中的上一篇(個(gè))和下一篇(個(gè))的程序代碼:
<%
id = TRIM(request("id"))
sqlPrev = "select top 1 * from news where id<" &id &" order by id desc"'上一篇(個(gè))讀取
sqlNext = "select top 1 * from news where id>" &id &" order by id"'下一篇(個(gè))讀取
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>上一篇文章:沒(méi)有了</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>下一篇文章:沒(méi)有了</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
%>
對(duì)產(chǎn)品的上一個(gè)產(chǎn)品,下一個(gè)產(chǎn)品同樣適用。