上一篇、下一篇的问题,急!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/15 20:19:04
哪位大哥帮我看下这段代码呀,我点上一篇的时候正常,但点下一篇的时候却到了最后一篇,代码如下:
上一篇:<%=nextart(id,1)%><br /><br />
下一篇:<%=nextart(id,2)%>
<%
function nextart(id2,o)
if o=1 then
sql="select top 1 * from zn where id>"&id2&" order by id"
end if
if o=2 then
sql="select top 1 * from zn where id<"&id2&" order by id"
end if
set rss=conn.execute(sql)
if rss.eof then
response.Write("没有了")
else
response.Write("<a href=yd_bxww.asp?id="&rss("id")&">"&rss("title")&"</a>")
end if
end function
%>

或哪位朋友给你们自己的代码也行,谢谢了
那要怎么写,能不能麻烦你帮我改下,成功之后追加分

if o=2 then
sql="select top 1 * from zn where id<"&id2&" order by id desc"
end if

看见没有,我在最后给你添加了DESC四个字符,这样就可以了。

id不因该是2

改成这样:
<%
function nextart(id2,o)
if o=1 then
sql="select top 1 * from zn where id>"&id2&" order by id"
end if
if o=2 then
sql="select top 1 * from zn where id<"&id2&" order by id desc"
end if
set rss=conn.execute(sql)
if rss.eof then
response.Write("没有了")
else
response.Write("<a href=yd_bxww.asp?id="&rss("id")&">"&rss("title")&"</a>")
end if
end function
%>
你的SQL语句问题!两个都是升序排列!