在asp生成静态页面的时候内容页中的上一篇和下一篇该如何实现
展开全部
以下代码为本站所用代码,供大家交流。
因为我们有时候会删除自己的文章,为了更好的实现这个功能所以本站选择JS代码实现这个功能。ID为自动编号。
html页面JS调用上一页代码
以下是引用片段:
<script src="http://www.51wisdom.com.cn/sec.asp?id=852"></script>
html页面JS调用下一页代码
以下是引用片段:
<script src="http://www.51wisdom.com.cn/next.asp?id=852"></script>
以下是引用片段:
sec.asp代码
<!--#include file="conn.asp"-->
<%
id=request.QueryString("id")
hits=conn.execute("select top 1 title from news where id<" &id&" order by id desc")(0)
Inid=conn.execute("select top 1 id from news where id<"&id&" order by id desc")(0)
response.write("document.write(""<FONT color=red>上一篇:<\/FONT><a href='../html/"&Inid&".html'>"&hits&"</a>"")")
%>
带判断的代码
<!--#include file="conn.asp"-->
<%
id=request.QueryString("id")
Set Rss=Server.CreateObject("adodb.recordset")
Sql="select top 1 *from news where id<"&id&" and show=true order by id desc"
Rss.Open SQL,Conn,1,1
If not Rss.EOF Then
response.write("document.write(""<FONT color=red>上一篇:<\/FONT><a href='../html/"&rss("id")&".html'>"&rss("title")&"</a>"")")
else
response.write("document.write(""<FONT color=red>上一篇:<\/FONT>没有了"")")
end if
Rss.Close
SET Rss=Nothing
%>
next.asp代码
<!--#include file="conn.asp"-->
<%
id=request.QueryString("id")
hits=conn.execute("select top 1 title from news where id<" &id&" order by id asc")(0)
Inid=conn.execute("select top 1 id from news where id<"&id&" order by id asc")(0)
response.write("document.write(""<FONT color=red>上一篇:<\/FONT><a href='../html/"&Inid&".html'>"&hits&"</a>"")")
%>
带判断的代码
<!--#include file="conn.asp"-->
<%
id=request.QueryString("id")
Set Rss=Server.CreateObject("adodb.recordset")
Sql="select top 1 *from news where id>"&id&" and show=true order by id asc"
Rss.Open SQL,Conn,1,1
If not Rss.EOF Then
response.write("document.write(""<FONT color=red>下一篇:<\/FONT><a href='../html/"&rss("id")&".html'>"&rss("title")&"</a>"")")
else
response.write("document.write(""<FONT color=red>下一篇:<\/FONT>没有了"")")
end if
Rss.Close
SET Rss=Nothing
%>
因为我们有时候会删除自己的文章,为了更好的实现这个功能所以本站选择JS代码实现这个功能。ID为自动编号。
html页面JS调用上一页代码
以下是引用片段:
<script src="http://www.51wisdom.com.cn/sec.asp?id=852"></script>
html页面JS调用下一页代码
以下是引用片段:
<script src="http://www.51wisdom.com.cn/next.asp?id=852"></script>
以下是引用片段:
sec.asp代码
<!--#include file="conn.asp"-->
<%
id=request.QueryString("id")
hits=conn.execute("select top 1 title from news where id<" &id&" order by id desc")(0)
Inid=conn.execute("select top 1 id from news where id<"&id&" order by id desc")(0)
response.write("document.write(""<FONT color=red>上一篇:<\/FONT><a href='../html/"&Inid&".html'>"&hits&"</a>"")")
%>
带判断的代码
<!--#include file="conn.asp"-->
<%
id=request.QueryString("id")
Set Rss=Server.CreateObject("adodb.recordset")
Sql="select top 1 *from news where id<"&id&" and show=true order by id desc"
Rss.Open SQL,Conn,1,1
If not Rss.EOF Then
response.write("document.write(""<FONT color=red>上一篇:<\/FONT><a href='../html/"&rss("id")&".html'>"&rss("title")&"</a>"")")
else
response.write("document.write(""<FONT color=red>上一篇:<\/FONT>没有了"")")
end if
Rss.Close
SET Rss=Nothing
%>
next.asp代码
<!--#include file="conn.asp"-->
<%
id=request.QueryString("id")
hits=conn.execute("select top 1 title from news where id<" &id&" order by id asc")(0)
Inid=conn.execute("select top 1 id from news where id<"&id&" order by id asc")(0)
response.write("document.write(""<FONT color=red>上一篇:<\/FONT><a href='../html/"&Inid&".html'>"&hits&"</a>"")")
%>
带判断的代码
<!--#include file="conn.asp"-->
<%
id=request.QueryString("id")
Set Rss=Server.CreateObject("adodb.recordset")
Sql="select top 1 *from news where id>"&id&" and show=true order by id asc"
Rss.Open SQL,Conn,1,1
If not Rss.EOF Then
response.write("document.write(""<FONT color=red>下一篇:<\/FONT><a href='../html/"&rss("id")&".html'>"&rss("title")&"</a>"")")
else
response.write("document.write(""<FONT color=red>下一篇:<\/FONT>没有了"")")
end if
Rss.Close
SET Rss=Nothing
%>
参考资料: http://www.51weidi.com/html/894.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询