asp网页页面中如何添加上一页 下一页代码

asp网页中如何添加上一页 下一页代码,
ASP页面中没有上一页和下一页代码,有没有方法可以添加进去?
望告知.谢谢.

代码如下:
<%
function thenext
newrs=server.CreateObject("adodb.recordset")
sql="select top 1 * from articles where id>"&a1&" order by id"
set newrs=conn.execute(sql)
if newrs.eof then
response.Write("没有了")
else
a2=newrs("id")
response.Write("<a href='view.asp?id="&a2&"'>下一篇</a>")
end if
end function
%>
'定义一个thehead函数来找出下一篇的ID,如果当前记录已经是最前面的一条记录,则输出文字“没有了”
<%
function thehead
headrs=server.CreateObject("adodb.recordset")
sql="select top 1 * from articles where id<"&a1&" order by id desc"
set headrs=conn.execute(sql)
if headrs.eof then
response.Write("没有了")
else
a0=headrs("id")
response.Write("<a href='view.asp?id="&a0&"'>上一篇</a>")
end if
end function
%>
'数据库连接文件
<!--#include file="conn.asp"-->
'取得传递过来的ID,显示文章标题作者和内容
<%
id=request("id")
sql="select * from articles where id="&id
set rs=conn.execute(sql)
%>
<%
boardid=rs("boardid")
%>
<title>文章系统-<% =rs("title") %></title>
<body leftmargin="0" topmargin="0">
<!--#include file="top.asp" -->
<%Do While Not rs.EOF%>
<table width="773" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="576" align="left"><table width="557" border="0" cellspacing="5" cellpadding="4" align="left"> <tr> <td colspan="2" align="center">
<span style="font-size:9pt color:#efefef"><%= rs("title") %><br> <div align="right">
<span style="font-size:9pt color:#efefef">作者:<%= rs("author") %></span></div> </span></td></tr><tr><td colspan="2" >
<span style="font-size:9pt color:#efefef">
<!--将数据库的资料取出,经过编码后输出,保持输入时的格式不变-->
<%= replace(server.HTMLEncode(rs("content")),chr(13),"<br>") %></span></td></tr><% a1=rs("id") %><tr><td width="269" align="right">
<!--调用前面定义的显示上一篇的函数-->
<% thehead %>
</td>
<td width="257" align="right">
<!--调用前面定义的显示下一篇的函数-->
<% thenext %></td></tr>
<% rs.MoveNext
Loop
%></table></td><td width="217" valign="top" align="left">相关文章:
'根据当前文章的栏目号,找出同一栏目的文章
<%sql="select * from articles where boardid="&boardid&""
set rs=conn.execute(sql)%>
<%Do While Not rs.EOF %>
<table width="207" border="0" cellspacing="2" cellpadding="2">
<tr>
<td height="20">
<a href="view.asp?id=<%=rs("id")%>">
<%= rs("title") %>
</a></td></tr></table>
<% rs.MoveNext%><%Loop%></td>
</tr>
</table>
<!--#include file="copyright.asp" -->
</body>
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-11-01
showpage.asp页面内容
--------------------------------------------------------------------------------------------------------
<%
'***********************************************
'函数名:PasteURL
'作 用:向地址中加入 ? 或 &
'参 数:strUrl ----网址
'返回值:加了 ? 或 & 的网址
'***********************************************
function PasteURL(strUrl)
if strUrl="" then
PasteURL=""
exit function
end if
'如果传入的URL末尾不是"?",有两种情况:
'1.无“?”,此时需加入一个“?”
'2. 有“?”再判断有无“&”
if InStr(strUrl,"?")<len(strUrl) then
if InStr(strUrl,"?")>1 then
if InStr(strUrl,"&")<len(strUrl) then
PasteURL=strUrl & "&"
else
PasteURL=strUrl
end if
else
PasteURL=strUrl & "?"
end if
else
PasteURL=strUrl
end if
end function

'***********************************************
'过程名:ShowPage
'作 用:显示“上一页 下一页”等信息
'参 数:sDesURL ----链接地址,可以是一个文件名,也可以是一个有一些参数所URL
' nTotalNumber ----总数量
' nMaxPerPage ----每页数量
' nCurrentPage ----当前页
' bShowTotal ----是否显示总数量
' bShowCombo ---是否用下拉列表显示所有页面以供跳转。有某些页面不能使用,否则会出现JS错误。
' sUnit ----计数刻度(如每页数条或每页多少个)
'***********************************************
sub ShowPage(sDesURL, nTotalNumber, nMaxPerPage, nCurrentPage, bShowTotal, bShowCombo, sUnit)
dim n, i,strTemp,strUrl
'计算页数
if nTotalNumber mod nMaxPerPage=0 then
n= nTotalNumber \ nMaxPerPage
else
n= nTotalNumber \ nMaxPerPage+1
end if
'判断nCurrentPage
if nCurrentPage < 1 then
nCurrentPage = 1
elseif nCurrentPage > n then
nCurrentPage = n
end if

Response.Write "<table style='border-top:1px solid #e5e3e6;width:100%;font-size:12px;height:14px;background:none;' align='center' ID='Table1'><form name='ShowPages' method='Post' action='" & sDesURL & "' ID='Form1'><tr><td><font size='-1' >"
if bShowTotal=true then
Response.Write "共 <b>" & nTotalNumber & "</b> " & sUnit & " "
end if
'根据输入的sDesURL向它加入?或&
strUrl=PasteURL(sDesURL)
if nCurrentPage<2 then
Response.Write "首页 上一页 "
else
Response.Write "<a href='" & strUrl & "page=1'>首页</a> "
Response.Write "<a href='" & strUrl & "page=" & (nCurrentPage-1) & "'>上一页</a> "
end if

if n-nCurrentPage<1 then
Response.Write "下一页 尾页"
else
Response.Write "<a href='" & strUrl & "page=" & (nCurrentPage+1) & "'>下一页</a> "
Response.Write "<a href='" & strUrl & "page=" & n & "'>尾页</a>"
end if
Response.Write " 页次:<strong><font color=red>" & nCurrentPage & "</font>/" & n & "</strong>页 "
Response.Write " <b>" & nMaxPerPage & "</b>" & sUnit & "/页"
if bShowCombo=True then
Response.Write " 跳转至:<SELECT name='page' size='1' onchange='javascript:submit()' ID='Select1'>"
for i = 1 to n
Response.Write "<option value='" & i & "'"
if cint(nCurrentPage)=cint(i) then Response.Write " selected "
Response.Write ">第" & i & "页</option>"
next
Response.Write "</SELECT>"
end if
Response.Write "</font></td></tr></form></table>"
end sub
%>

实例引用页面内容
--------------------------------------------------------------------------------------------------------
<!--#include file="conn.asp"-->
<!--#include file="showpage.asp"-->

<%
'显示相关列表
sql2="select * from IM_P_Blog order by hits desc"
set rs2=server.createobject("adodb.recordset")
rs2.open sql2,conn,3,2

'分页部分
CurrentPage = Request("page")
if Not IsNumeric(CurrentPage) Then
CurrentPage = "1"
end if
if rs2.EOF Then
response.write("暂无相关讨论主题...<br/>")
Response.End
end if
CurrentPage=Cint(CurrentPage)
'自定义每页显示信息数
rs2.PageSize =30

'默认信息 conMaxPerPage_Default
If CurrentPage < 1 Then CurrentPage = 1
If CurrentPage > rs2.PageCount Then
CurrentPage = rs2.PageCount
end if
rs2.AbsolutePage = CurrentPage
if not rs2.eof then
i=1
do while not rs2.eof
'这里显示分面列表中的内容
'自己发挥
'/********************************************/

i=i+1
if i>rs2.PageSize then exit do
rs2.movenext
loop

end if
'调用页面函数
call showpage("bloglist.asp", rs2.RecordCount, rs2.PageSize, CurrentPage, true, true, "项")
%>

注释:以上直接套用就可以了。其中以下
'这里显示分面列表中的内容
'自己发挥
'/********************************************/
为你自己分页页面内容显示。如不懂,可以Qme334194041
第2个回答  2021-02-19

WP开发21:wordpress网站文章页模板,如何调用文章的标题、内容、标签等信息?

第3个回答  2009-11-01
自己写
关键字: ASP中SQL分页
第4个回答  2009-11-10
发给你了.你查收一下本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网