数据库记录分页显示代码

发布时间:2007年07月08日      浏览次数:1643 次
<%
      set conn=server.createobject("adodb.connection")
      set rst=server.createobject("adodb.recordset")
      DBPath = Server.MapPath("/data/usrdata.mdb")
      conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
%>
<html>
<head>
<style type="text/css"><!--
table,body {font-size: 9pt;color:green} -->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body topmargin=0 leftmargin=0>
<%
page=cint(Request.QueryString("page"))
if page="" or page=0 then
page=1
end if
rst.cursortype=adopenstatic
sql="select id,name,email,tname,sex,QQ,address,regdate from user order by regdate desc "
count=conn.execute("select count(name)from [user]")(0)
on error resume next
rst.open sql,conn
pagesetup=20
If Count/pagesetup > (Count\pagesetup) then
TotalPage=(Count\pagesetup)+1
else
TotalPage=(Count\pagesetup)
End If
RSt.MoveFirst
rst.move (page-1)*pagesetup
if not rst.eof then
%>
<table border="1" width="100%" cellspacing=0 bordercolor=black>
<tr>
<th ><font color=red>编号</font></th>
<th ><font color=red>会员账号</font></th>
<th ><font color=red>电子邮箱</font></th>
<th ><font color=red>真实姓名</font></th>
<th ><font color=red>性别</font></th>
<th ><font color=red>QQ号码</font></th>
<th ><font color=red>详细地址</font></th>
<th ><font color=red>注册时间</font></th>
</tr>
<%
rcount=0
while not rst.eof and rcount<pagesetup %>
<tr bordercolor="white">
<% for i=0 to rst.fields.count-1 %>
<td><% =rst(i)%></td>
<% next %>
</tr>
<%
rcount=rcount+1
rst.movenext
wend
%>
</table>
<hr size=1 colr=green>
<p>共<%=count%> 个记录 每页有<%=pagesetup%>个记录 共<%=TotalPage%>页 当前页次:<% =page %>
<% for i=1 to totalpage
if i=page then %>
<font color=red>[<%=i%>]</font>
<%else%>
<a class=a1 href="<%=Request.ServerVariables("SCRIPT_NAME")%>?page=<%=i%>">[<%=i%>]</a>
<%
end if
next
else
%>
<p align="center">当前没有记录!</p>
<% end if %>
</body>
</html>
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!