用asp如何写上一篇文章和下一篇文章功能呢
用asp如何写上一篇文章和下一篇文章功能呢就是打开一篇文章下面有,上一篇 下一篇 这个功能 上一篇 就是ID小于当前ID的最大值
下一篇 就是ID大于当前ID的最小值 [code]Function dispUp() '显示上一条标题
reVal="aa"
if id&""<>"" and isnumeric(id) then
set rsu=Server.CreateObject("ADODB.Recordset")
sql="Select top 1 ID,标题,URL from [tab] where id>"&id&" order by id"
rsu.open sql,conn,1,1
if rsu.eof then
reVal="无"
else
if rsu("URL")&""<>"" then
tmpU="<a title='"&rsu("标题")&"' href='News.asp?id="&rsu("id")&"' "& rsu("URL") &">"
else
tmpU="<a title='"&rsu("标题")&"' href='News.asp?id="&rsu("id")&"' >"
end if
reVal=tmpU&cutstr(rsu("标题"),18)&"</a>"&VBCR
end if
rsu.close
set rsu=nothing
end if
dispUp=reVal
End Function[/code]
显示下一条稍微改变一下就可以了 [url]http://search.blueidea.com/?q=%E4%B8%8A%E4%B8%80%E7%AF%87&tr=bbs[/url] 当前文章的ID加1不就是下一篇,而当前文章的ID减1不就是上一篇了?
有什么问题吗?还是我理解错了? 中间有可能删除记录过的,所以光加ID是不行的。
1,2,3,4,5,删除了2这个记录,1的话光加ID能得出3不? 楼上的朋友心细啊,惭愧惭愧。
如果是这样的话,那直接Skip了。 2楼貌似正解哦,呵呵 用法:当前id是第五条,我要取上一条和下一条:
上一条(取上一条一定要将id排倒序)
sql = "select top 1 a_title from tbl_article where a_id<"+a_id+" order by a_id desc";
下一条
sql = "select top 1 a_title from tbl_article where a_id>"+a_id+" order by a_id asc";
页:
[1]