收藏了一个比较快的翻页,使用方便哦!
程序如下:
<%'显示翻页(数据库,查询条件,每页个数,页面名称,当前页数,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=" <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>条记录 每页"&geshu&"条 当前第<font color='#FF0000'>"&page&"</font>页/共"&ye&"页 "&shouye&" "&shangyiye&" "&xiayiye&" "&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)%>
程序如下:
<%'显示翻页(数据库,查询条件,每页个数,页面名称,当前页数,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=" <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>条记录 每页"&geshu&"条 当前第<font color='#FF0000'>"&page&"</font>页/共"&ye&"页 "&shouye&" "&shangyiye&" "&xiayiye&" "&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)%>