求助:ASP网页中实现“上一篇”“下一篇”代码
asp网页,文章详细页面,需要实现上一篇下一篇功能。access数据库中,数据表news中有这些字段,Nid,Ntitle,Ntype网页格式为www.baidu.com...
asp网页,文章详细页面,需要实现上一篇下一篇功能。
access数据库中,数据表news中有这些字段,Nid,Ntitle,Ntype
网页格式为www.baidu.com/News.asp?N_Type=1&N_id=1
请帮忙写出一个代码。 展开
access数据库中,数据表news中有这些字段,Nid,Ntitle,Ntype
网页格式为www.baidu.com/News.asp?N_Type=1&N_id=1
请帮忙写出一个代码。 展开
3个回答
展开全部
我自己用的函数,你根据实际稍微改动即可:
function exlist(N_id,N_Type)
sqlprev = "select top 1 * from news where ID > "&N_id&" and Ntype="&N_Type&" order by id asc"
sqlnext = "select top 1 * from news where ID < "&N_id&" and Ntype="&N_Type&" order by id desc"
set rs = conn.execute(sqlprev)
if(not rs.eof)then
url = "?N_Type="&rs("Ntype")&"&N_id="&rs("Nid")
response.write "<span>上一新闻:<a href="""&url&""">"&rs("Ntitle")&"</a></span><br />"
else
response.write "<span>上一新闻:无</span><br />"
end if
set rs = conn.execute(sqlnext)
if(not rs.eof)then
url = "?N_Type="&rs("Ntype")&"&N_id="&rs("Nid")
response.write "<span>下一新闻:<a href="""&url&""">"&rs("Ntitle")&"</a></span><br />"
else
response.write "<span>下一新闻:无</span><br />"
end if
set rs=nothing
end function
调用 <% call exlist(N_id,N_Type) %>
function exlist(N_id,N_Type)
sqlprev = "select top 1 * from news where ID > "&N_id&" and Ntype="&N_Type&" order by id asc"
sqlnext = "select top 1 * from news where ID < "&N_id&" and Ntype="&N_Type&" order by id desc"
set rs = conn.execute(sqlprev)
if(not rs.eof)then
url = "?N_Type="&rs("Ntype")&"&N_id="&rs("Nid")
response.write "<span>上一新闻:<a href="""&url&""">"&rs("Ntitle")&"</a></span><br />"
else
response.write "<span>上一新闻:无</span><br />"
end if
set rs = conn.execute(sqlnext)
if(not rs.eof)then
url = "?N_Type="&rs("Ntype")&"&N_id="&rs("Nid")
response.write "<span>下一新闻:<a href="""&url&""">"&rs("Ntitle")&"</a></span><br />"
else
response.write "<span>下一新闻:无</span><br />"
end if
set rs=nothing
end function
调用 <% call exlist(N_id,N_Type) %>
追问
没看明白,这些代码加到哪里啊,能QQ沟通一下吗?我加分
追答
代码放在那个要使用的页面
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询