一个比较好的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翻页一个小问题

12-09

rn原本我只有一个RS的时候,可以达到翻页效果的功能。rnrn但是我增加了3个RS1,RS2,RS3之后,我发觉我打翻页功能翻来翻去,都是打开了同样的产品rnrn也就是无论page1,page2,page3,看来看去也是那样产品。。。rnrnrn[code=HTML]rndim id,company,intro,graph2,description,remarks,price,price2,rs2,strSorts,strCategory,rs,rs3,rs2rnid=Int(saferequest("id",1))rnrnrnset rs2=server.CreateObject("adodb.recordset")rnsql="select * from product order by ID desc"rnrs2.open sql,conn,1,1rnif rs2.eof and rs2.bof thenrnresponse.Write "暂无产品上架"rnresponse.Endrnend ifrnrs2("viewnum")=rs2("viewnum")+1rnrs2.update rnIntCatID = rs2("categoryid")rnIntCatIDLong=IntCatIDrnrn set rs3=server.CreateObject("adodb.recordset")rn if IntCatID = 0 thenrn rs3.open "Select categoryid,category,ParentID From category Where categoryid="&IntCatID,conn,1,1rn if r3s.eof and rs3.bof thenrn response.Write " "rn rs3.closern set rs3 = Nothingrn conn.Closern set conn=nothingrn response.endrn end ifrnrn strCategory = ""&rs3("category")&"->"&strCategoryrn TitleCategory = TitleCategory&""&rs3("category")&"->"rn IntCatID = rs3("ParentID")rn IntCatIDLong=CStr(IntCatIDLong)&","&CStr(rs3("ParentID"))rn end if rnset rs3 = nothingrn%> rnrn<%rn'---------- 页面设计 -----------rndim i,intPage,page,pre,last,filepathrnset rs=server.createobject("adodb.recordset")rnmssql="select * from product order by ID desc"rnrs.open mssql,conn,1,1rnrs.pagesize=6rnpre = truernlast = truernpage = trim(Request.QueryString("page"))rnrnif len(page) = 0 thenrnintpage = 1rnpre = falsernelsernif cint(page) =< 1 thenrnintpage = 1rnpre = falsernelsernif cint(page) >= rs.PageCount thenrnintpage = rs.PageCountrnlast = falsernelsernintpage = cint(page)rnend ifrnend ifrnend ifrnif not rs.eof thenrnrs.AbsolutePage = intpagernend ifrn%>rn[/code]rnrnrnrn[code=HTML]rnrn<%if rs.pagecount > 0 then%>rn当前页<%=intpage%>/<%=rs.PageCount%>rn<%else%>rn当前页0/0<%end if%>rn 首页| rn<%if pre then%>rn上页| <%end if%>rn<%if last then%>rn下页 |<%end if%>rn尾页|转到第rnrn<%rnfor i = 1 to rs.PageCountrnif i = intpage then%>rn<%=i%>rn<%else%>rn<%=i%>rn<%rnend rnifrnnextrn%>rn页 rn[/code] 论坛

没有更多推荐了,返回首页