打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
分页代码
userphoto

2011.03.29

关注
今天闲来没事,简单写了个有关分页的代码,顺便放在网站上,以便于以后参考,只适用于新手,高手就飘过吧。
代码如下:

代码
<<A href="mailto:%@LANGUAGE=\" VBSCRIPT?>%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>分页</title>
<script type="text/javascript">
  function enterkey(){
    if(event.keyCode==13){
   window.wdf.submit();
 }
  }
</script>
</head>
<body style="text-align:center;">
<%
  '建立数据库连接
  set conn=server.createobject("adodb.connection")
  connstr="provider=microsoft.jet.oledb.4.0;data source="&server.mappath("Data/#database#.mdb")
  conn.open connstr
  set rs=server.createobject("adodb.recordset")
  sql="select * from fy id "
  rs.open sql,conn,3,3
 
  rs.pagesize=13 '每页的记录个数
  pagesize1=rs.pagesize
  totalrecords=rs.recordcount '总共记录数
  totalpages=rs.pagecount '总共页数
  '得到当前页
  page=cstr(request("page"))
  if page="" then
    page=1
  elseif cint(page)>cint(totalpages) then
    page=totalpages
  elseif cint(page)<1 then
    page=1
  end if
  '定位到当前页
  rs.absolutepage=page
  n=1
  while n<=rs.pagesize and not rs.eof
    response.write rs("content")&"<br>"
 rs.movenext
 n=n+1
  wend
%>
<span style="color:red;"><%=page%></span>/<%=totalpages%>  每页<%=pagesize1%>条  共<%=totalrecords%>条记录   
<%
  '页面连接
  if cstr(page)="1" then
    response.write "首页  上一页"
  else
    response.write "<a href='?page=1'>首页</a>  <a href='?page="&page-1&"'>上一页</a>  "
  end if
 
 
 
 
  if cstr(page)=cstr(totalpages) then
    response.write "   下一页  尾页"
  else
    response.write "   <a href='?page="&page+1&"'>下一页</a>  <a href='?page='"&totalpages&"'>尾页</a>"
  end if
 
 '可以转到相应的页面,输入完数字后,也可直接按回车键
%>
<form name="wdf" action="?" style="padding:0px;margin:0px;display:inline;">
<input type="text" name="page" style="width:20px;" onkeydown="enterkey();">
<input type="submit" value="GO">
</form>
</body>
</html>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
在ASP中轻松实现记录集分页显示 >> 正文
MVC中分页的实现
ASP分页代码的学习
2个通用的ASP分页方法
最优化的ms sql server分页sql语句
JAVA MYSQL做分页
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服