asp页面怎么实现上一篇下一篇的功能啊??麻烦高手告诉我,详细点~我asp刚刚学~~我重新把网页代码发一下
<%ifrequest.QueryString("id")=""thenresponse.Write"<script>alert('参数错误!');"response.W...
<%
if request.QueryString("id")="" then
response.Write "<script>alert('参数错误!');"
response.Write "window.location.href='index.asp';</script>"
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from Information where key='news' and I_id="& request.QueryString("id")
rs.open sql,conn,1,3
%>
<link href="inc/css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE3 {font-size: 16px}
.STYLE4 {font-size: 18px}
.STYLE5 {font-size: 14}
.STYLE6 {font-size: 14px}
-->
</style>
</head>
<body>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3"><!--#include file="inc/head.asp"--></td>
</tr>
<tr>
<td width="220" align="right" valign="top">
<!--#include file="inc/login.asp"-->
<!--#include file="inc/search.asp"-->
<!--#include file="inc/link.asp"-->
<!--#include file="inc/down.asp"--></td>
<td width="25"> </td>
<td width="555" valign="top">
<table width="1%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="image/bg.jpg"/></td>
</tr>
<tr>
<td><img src="image/news.jpg" alt="就业新闻" width="309" height="34" border="0" usemap="#Map2" />
<map name="Map2" id="Map2">
<area shape="rect" coords="20,6,85,28" href="news.asp" alt="返回就业新闻" />
</map></td>
</tr>
</table>
<table width="550" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="30" rowspan="5"> </td>
<td width="431" class="STYLE3"><font color="#000080"><span lang="zh-cn"><font color=#000080><span class="STYLE6">当前位置:<a href= index.asp><font color=#000080>首页</font></a> >>> <font color=#000080><a href="news.asp">就业新闻</a></font><font color=#000080></font></span></span></font>
<% rs.open "select I_id,I_title from Information where I_id <"&I_id,conn,1,1 %>
<a href=news.asp?id=<%=rs("I_id")%>>上一篇</a>
<% rs.open "select I_id,I_title from Information where I_id > "&I_id,conn,1,1 %>
<a href=news.asp?id=<%=rs("I_id")%>>下一篇</a>
我这样写为什么还不行啊?? 展开
if request.QueryString("id")="" then
response.Write "<script>alert('参数错误!');"
response.Write "window.location.href='index.asp';</script>"
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from Information where key='news' and I_id="& request.QueryString("id")
rs.open sql,conn,1,3
%>
<link href="inc/css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE3 {font-size: 16px}
.STYLE4 {font-size: 18px}
.STYLE5 {font-size: 14}
.STYLE6 {font-size: 14px}
-->
</style>
</head>
<body>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3"><!--#include file="inc/head.asp"--></td>
</tr>
<tr>
<td width="220" align="right" valign="top">
<!--#include file="inc/login.asp"-->
<!--#include file="inc/search.asp"-->
<!--#include file="inc/link.asp"-->
<!--#include file="inc/down.asp"--></td>
<td width="25"> </td>
<td width="555" valign="top">
<table width="1%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="image/bg.jpg"/></td>
</tr>
<tr>
<td><img src="image/news.jpg" alt="就业新闻" width="309" height="34" border="0" usemap="#Map2" />
<map name="Map2" id="Map2">
<area shape="rect" coords="20,6,85,28" href="news.asp" alt="返回就业新闻" />
</map></td>
</tr>
</table>
<table width="550" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="30" rowspan="5"> </td>
<td width="431" class="STYLE3"><font color="#000080"><span lang="zh-cn"><font color=#000080><span class="STYLE6">当前位置:<a href= index.asp><font color=#000080>首页</font></a> >>> <font color=#000080><a href="news.asp">就业新闻</a></font><font color=#000080></font></span></span></font>
<% rs.open "select I_id,I_title from Information where I_id <"&I_id,conn,1,1 %>
<a href=news.asp?id=<%=rs("I_id")%>>上一篇</a>
<% rs.open "select I_id,I_title from Information where I_id > "&I_id,conn,1,1 %>
<a href=news.asp?id=<%=rs("I_id")%>>下一篇</a>
我这样写为什么还不行啊?? 展开
展开全部
以下代码为本站所用代码,供大家交流。
因为我们有时候会删除自己的文章,为了更好的实现这个功能所以本站选择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.51wisdom.com.cn/html/894.html
展开全部
这是一个参考文档,希望对你有用
ASP实现页面的“上一篇、下一篇”功能 http://www.wdzz.net/Design/pages/200906/406.html
ASP实现页面的“上一篇、下一篇”功能 http://www.wdzz.net/Design/pages/200906/406.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询