注册 登录
编程论坛 ASP技术论坛

上一篇和下一篇代码-主题-显示不出来

osvi 发布于 2012-05-19 06:47, 404 次点击
dim preid,nextid
set rst=server.CreateObject("adodb.recordset")
set rst=conn.execute("select max(id) from news where id<"&rs("id"))
preid=rst(0)
if isnull(preid) or preid=0 then
    preid=rs("id")
end if
set rst=conn.execute("select min(id) from news where id>"&rs("id"))
nextid=rst(0)
if isnull(nextid) or nextid=0 then
    nextid=rs("id")
end if
set rst=nothing


<!--代码位置-->

上一篇:<a href= "maker.asp?id=<%=preid%>"><%=rs("title")%></a>


大家帮我看看,这段代码, 我是希望上一篇后面能 显示出该篇的主题。 我现在的这个<%=rs("title")%>显示出来的是当前篇的主题。
请帮忙看看,谢谢

我是想要类似:
上一篇: 香港某大学最新新闻
下一篇: 知名媒体华丽转身

[ 本帖最后由 osvi 于 2012-5-19 14:56 编辑 ]
1 回复
#2
wangjy5002012-05-20 19:59
dim preid,nextid,ptitle,ntitle
set rst=server.CreateObject("adodb.recordset")
set rst=conn.execute("select max(id) from news where id<"&rs("id"))
preid=rst(0)
ptitle=rst(1)
if isnull(preid) or preid=0 then
    preid=rs("id")
   ptitle=rs("title")
end if
set rst=conn.execute("select min(id) from news where id>"&rs("id"))
nextid=rst(0)
ntitle=rst(1)
if isnull(nextid) or nextid=0 then
    nextid=rs("id")
   ntitle=rs("title")
end if
set rst=nothing

上一篇:<a href= "maker.asp?id=<%=preid%>"><%=ptitle%></a>
1