本人觉得楼主的代码有个缺陷,该代码只能适用于连续的ID,当ID不连续的时候会出现“无法浏览”
以下为我使用的方式
-----------------------------------------------------------------------------------------------------------------------------
<%'向下向上翻页功能模块
function thenext '下篇文章
newrs=server.CreateObject("adodb.recordset")
sql="select top 1 * from product where id>"&id&" and smallclassid="&rspp("smallclassid")&" order by id"
set newrs=conn.execute(sql)
if newrs.eof then
response.Write"<img src='images/DD5.jpg' alt='下一件商品' width='15' height='13' border='0'>"
else
a2=newrs("id")
response.Write ("<a href='products.asp?id="&a2&"&smallclassid="&rspp("smallclassid")&"'>")
response.Write
"<img src='images/DD5.jpg' alt='下一件商品:"&newrs("name")&"' width='15' height='13' border='0'>"
response.Write ("</a>")
end if
end function
'下一篇文章功能结束
'上一篇文章
function thehead
headrs=server.CreateObject("adodb.recordset")
sql="select top 1 * from product where id<"&id&" and smallclassid="&rspp("smallclassid")&" order by id desc"
set headrs=conn.execute(sql)
if headrs.eof then
response.Write"<img src='images/DD6.jpg' alt='上一件商品' width='15' height='13' border='0'>"
else
a0=headrs("id")
AA= headrs("name")
response.Write ("<a href='products.asp?id="&a0&"&smallclassid="&rspp("smallclassid")&"'>")
response.Write "<img src='images/DD6.jpg' alt='上一件商品:"&aa&" ' width='15' height='13' border='0'>"
response.write ("</a>")
end if
end function%>
在需要使用 上一篇或下一篇 时 直接调用<% thenext %>或<% thehead %> 即可
-----------------------------------------------------------------------------------------------------------------------------
" border="0" />