ASP高手帮忙看看这段代码..上篇文章和下篇

来源:百度知道 编辑:UC知道 时间:2024/07/02 14:19:32
set rs=server.createobject("adodb.recordset")
sql="select top 1 id,CnTitle from [News] where id<"&id&" order by id desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
%><p><li>上篇文章:已经没有了
<%else%>
<p><li>上篇文章:<a href="list.asp?id=<%=rs("id")%>"><%=rs("CnTitle")%></a>
<%
end if%>
<BR>
<%
set rs=server.createobject("adodb.recordset")
sql="select top 1 id,CnTitle from [News] where id>"&id&""
rs.open sql,conn,1,1
if rs.eof and rs.bof then
%>
<li>下篇文章:已经没有了
<%
else
%>
<li>下篇文章:<a href="list.asp?id=<%=rs("id")%>"><%=rs("CnTitle")%></a>
<%end if%>

----------------------------------------------------

把下面的内容定义成函数,如function showtitle():
set rs=server.createobject("adodb.recordset")
sql="select top 1 id,CnTitle from [News] where id<"&id&" order by id desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
%><p><li>上篇文章:已经没有了
<%else%>
<p><li>上篇文章:<a href="list.asp?id=<%=rs("id")%>"><%=rs("CnTitle")%></a>
<%
end if%>
<BR>
<%
set rs=server.createobject("adodb.recordset")
sql="select top 1 id,CnTitle from [News] where id>"&id&""
rs.open sql,conn,1,1
if rs.eof and rs.bof then
%>
<li>下篇文章:已经没有了
<%
else
%>
<li>下篇文章:<a href="list.asp?id=<%=rs("id")%>"><%=rs("CnTitle")%></a>
<%end if%>
然后在要显示文章导航的地方调用函数:<%call s