一个比较好的ASP翻页!

收藏了一个比较快的翻页,使用方便哦!
程序如下:
<%'显示翻页(数据库,查询条件,每页个数,页面名称,当前页数,get后缀)
function fanye(db,tiaojian,geshu,yemian,page,gets)
sql="SELECT COUNT(*) AS co FROM "&db&tiaojian
set rszongshu = server.CreateObject ("adodb.recordset")
rszongshu.open sql,conn,1,1
zongshu=rszongshu("co")
rszongshu.close
set rszongshu=nothing
yu=zongshu mod geshu
ye=int(zongshu/geshu)
 if yu<>0 then
 ye=ye+1
 end if
shangye=page-1
xiaye=page+1
 if shangye<1 then
 shangye=1
 end if
 if xiaye>ye then
 xiaye=ye
 end if
 if gets<>"" then
  gets="&"&gets
 end if
 if int(page)<=1 then
 shouye="首页"
 shangyiye="上一页"
 else
 shouye="<a href='"&yemian&"?page=1"&gets&"'>首页</a>"
 shangyiye="<a href='"&yemian&"?page="&shangye&gets&"'>上一页</a>"
 end if
 if int(page)>=ye then
 xiayiye="下一页"
 weiye="尾页"
 else
 xiayiye="<a href='"&yemian&"?page="&xiaye&gets&"'>下一页</a>"
 weiye="<a href='"&yemian&"?page="&ye&gets&"'>尾页</a>"
 end if
xuan="&nbsp;<select name='select' onChange='var jmpURL=this.options[this.selectedIndex].value ; if(jmpURL!=null) {window.location=jmpURL;} else {this.selectedIndex=0;}'>"
for j=1 to 21
pages=page+j-11
if pages>0 and pages<=ye then
xuan=xuan&"<option value='?page="&pages&gets&"'"
 if pages=int(page) then
 xuan=xuan&" selected"
 end if
 xuan=xuan&" class='button1'>第"&pages&"页</option>"
end if
next
xuan=xuan&"</select>"
fanye="共<font color='#FF0000'>"&zongshu&"</font>条记录&nbsp;每页"&geshu&"条&nbsp;当前第<font color='#FF0000'>"&page&"</font>页/共"&ye&"页&nbsp;"&shouye&"&nbsp;"&shangyiye&"&nbsp;"&xiayiye&"&nbsp;"&weiye&xuan
end function
%>
在你要放翻页信息的地方用下面的代码:
tablename:指表名;***.asp指翻页所在页.
<%   set rs=server.CreateObject ("adodb.recordset")
      '每页个数
      geshu=15
      '翻页变量page
      page=request.QueryString("page")
      if page="" or page<1 then
          page=1
      end if
     '根据翻页指定不同的sql语句
      if page=1 then
          sql="select top "&geshu&" * from tablename "&gets&" order by id desc"
      else
          jishu=(page-1)*geshu
          sql="SELECT TOP "&geshu&" * FROM tablename WHERE (id<(SELECT MIN(id) FROM (SELECT TOP "&jishu&" id FROM tablename"&gets&" ORDER BY id desc) AS TempTable))"&replace(gets,"where","and")&" ORDER BY id desc"
      end if
      rs.open sql,conn,1,1%>

<%=fanye("tablename",gets,geshu,"***.asp",page,houzhui)%>
/*-----ASP多功能翻页函数-------*/ Name:Asp多功能翻页函数 Version:2.0 Author:shemily /*------------------------------------*/ 一、目录说明 CSS ——css控制文件 Data ——Access数据库 Inc ——头文件目录 conn.asp ——数据库连接文件(需要设置数据库目录) Turn.inc ——翻页函数 vbDecode.inc ——asp字符过滤函数 ch2utf8.inc ——gb2312转utf8函数 JS ——javascript文件 二、函数使用说明 1、功能介绍: 以表格形式显示数据,通过CSS文件控制样式; 提供全选、记录被选项ID、点击列名进行排序; 可控显示修改、删除链接; 附加打印功能; 2、使用示例: dim sql,thepage,shownum,page,pagenum,linkpage sql="select * from xxxx" thepage="XXX.asp" '使用函数本页文件名 shownum=20 '每页显示数量 alterpage="XXX.asp" '修改链接页面 delpage="XXX.asp" '删除链接页面 call ShowTable(sql,thepage,shownum,page,pagenum,1,alterpage,delpage,"修改",1) '修改字样也可根据实际链接功能设置为其他文字 3、参数说明: function ShowTable(sql,thepage,shownum,page,pagenum,checkbox,alterpage,delpage,dowhat,ifdel) sql 数据库查询语句; thepage 用来分页显示数据的页面名称; shownum 每页显示数据条数 page 当前显示的页码 pagenum 返回总页数 alterpage 修改或查看页面(可含删除) delpage 删除页面 checkbox 是否需要复选框 0 为开 1 为关闭 其value 记录查询语句中第一个字段值,一般设为id值 2-width-height-top-left为弹出窗口加宽、高、上边距、左边距 3-width-height-top-left为弹出窗口加宽、高、上边距、左边距,含checkbox ifdel 是否需要修改、删除页面 0为开 1为关闭 2为只显示修改或者查看链接 4、使用示例: 见目录下的exam.asp 或者点击下面连接:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值