分页问题 简单 简单 简单 拜托帮忙!

mazhihuei 2005-05-23 02:26:16
做一个分页 页面 每页显示5页
假设连接一个数据库 PUBS 取出内容 ID
谢谢各位了
...全文
63 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
随缘而聚 2005-05-23
  • 打赏
  • 举报
回复
自己改改用了。

<%
Dim intPage
intPage=trim(Request.QueryString("page"))
if intPage="" or isEmpty(intPage) then
intPage=1
end if

intPageSize=5 '一面显示5条留言记录

set rs=server.createobject("adodb.recordset")
strSql="select * from guestbook order by time1 DESC"
rs.open strSql,conn,3,1
if not rs.eof then
intRecordCount=rs.RecordCount
rs.PageSize=intPageSize
intPageCount=rs.PageCount
intI=1
rs.AbsolutePage=intPage
do while not rs.eof and intI<=intPageSize
%>
<table width="600" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#003399" style="border-collapse:collapse;">
<tr>
<td width="100"><font color="#000080">姓名:</font> </td>
<td width="77%"><%=rs("name1")%></td>
</tr>
<tr>
<td><font color="#000080">email:</font> </td>
<td><%=rs("email1")%></td>
</tr>
<tr>
<td><font color="#000080">主题:</font> </td>
<td><%=rs("object1")%></td>
</tr>
<tr>
<td valign="top"><font color="#000080">留言:</font> </td>
<td>
<%
strMemo=rs("memo1")
if strMemo <>"" then
strMemo = replace(strMemo," "," ")
strMemo = replace(strMemo," ","  ")
strMemo = replace(strMemo,vbcrlf,"<br>")
response.write strMemo
else
response.write " "
end if
%>
</td>
</tr>
</table>
<br>
<%
intI=intI+1
rs.movenext
loop
end if
rs.close
set rs=nothing
set conn=nothing

%>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<%
'分页
if intPageCount<2 then
response.write "首页    "
response.write "上一页    "
response.write "下一页    "
response.write "末页"
else
if cint(intPage)<=1 then
response.write "首页    "
response.write "上一页    "
response.write "<a href=""book.asp?page="&cint(intPage)+1&""">下一页</a>    "
response.write "<a href=""book.asp?page="&intPageCount&""">末页</a>"
elseif cint(intPage)>=cint(intPageCount) then
response.write "<a href=""book.asp?page=1"">首页</a>    "
response.write "<a href=""book.asp?page="&cint(intPage)-1&""">上一页</a>    "
response.write "下一页    "
response.write "末页"
else
response.write "<a href=""book.asp?page=1"">首页</a>    "
response.write "<a href=""book.asp?page="&cint(intPage)-1&""">上一页</a>    "
response.write "<a href=""book.asp?page="&cint(intPage)+1&""">下一页</a>    "
response.write "<a href=""book.asp?page="&intPageCount&""">末页</a>"
end if
end if
%>    
<%=intPage%>页/<%=intPageCount%>页  每页<%=intPageSize%>条留言  共<%=intRecordCount%>条留言
</td>
</tr>
</table>
baggio2008 2005-05-23
  • 打赏
  • 举报
回复
<%
set rs=Server.CreateObject("Adodb.RecordSet")
sqlstr="select * from data" '精品推荐
rs.open sqlstr,conn,1,3

link="CustomerView.asp?SearchText="&SearchText&"&" '翻页
if rs.eof<>true then
if not isempty(request("page")) then
pagecount=cint(request("page"))
else
pagecount=1
end if
rs.pagesize=10
if pagecount>rs.pagecount or pagecount<=0 then
pagecount=1
end if
rs.AbsolutePage=pagecount
if pagecount=1 then
page_start=1
end if
if pagecount*rs.pagesize=>rs.recordcount then
page_end=rs.recordcount
end if
i=0
end if
%>
----------------------------------------------------------------------------
<%
sub Page '分页
response.write"<form name='go2to' form method=Post action="&link&">"
if pagecount=1 then
response.write "首页 上一页 "
else
response.write "<a class=title href="&link&"page=1>首页</a> "
response.write "<a class=title href="&link&"page="&cstr(pagecount-1)&">上一页</a> "
end if
if rs.PageCount-pagecount<1 then
response.write "下一页 尾页"
else
response.write "<a class=title href="&link&"page="&cstr(pagecount+1)&">下一页</a> "
response.write "<a class=title href="&link&"page="&cstr(rs.PageCount)&"><font class=ver>尾页</font></a>"
end if
response.write " 页次:"&pagecount&"/"&rs.pagecount&"页"
response.write "转到第<input class='inputnormal' type='text' name='page' size=2 maxLength=3 style='font-size: 9pt; color:#00006A; position: relative; height: 18' value="&PageCount&">页 "
response.write ("<input type='button' name='GO' value='GO' onclick=check('"&link&"')>")
response.Write "</form>"
end sub
%>


自己改吧 呵呵

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧