ASP带数字的最好分页方法

<%
      strSQL="Select * From v_web_product Where mn_id=" & strCurrMenu & strQuery & " Order by p_code,ID Desc"
      Set rs=Server.CreateObject("ADODB.RecordSet")
      rs.open strSQL,conn,1,1
      '分页显示初始化
      page=GetVariable("page")
      if page="" then
       page=1
      else
       page=Cint(page)
      end if
     
      Section=GetVariable("section")
      if Section="" then
       Section=1
      else
       Section=Cint(Section)
      end if
      '变量赋值
      intPageSize=9   '每页显示记录数
      intSectionSize=5   '多少页为一段,像GOOGLE一样
      PrevSectionText="<FONT face=webdings>7</FONT>"   '上一段的链接文字
      NextSectionText="<FONT face=webdings>8</FONT>"   '下一段的链接文字
      PrevPageText="<FONT face=webdings>3</FONT>"    '上页的链接文字
      NextPageText="<FONT face=webdings>4</FONT>"    '下页的链接文字
     
      strPageUrl="?class=" & GetVariable("class") & "&key=" & GetVariable("key") & "&price1=" & GetVariable("price1") & "&price2=" & GetVariable("price2")
     
      rs.pagesize=intPageSize
      intCount=rs.RecordCount
      intPageCount=rs.pagecount
      intSectionCount=(intPageCount - 1) / intSectionSize + 1
      if intCount>0 then
       rs.AbsolutePage=page
      end if
      %>
            <br>
            <%
      '循环输出
      ' for i=1 to (intPageSize + 1) / 2
      for i=1 to 3
       if rs.eof then exit for
      %>
            
             <%''循环体%>
            
                  <%rs.movenext
      next
     %>
   
              <%next%>
               共有<font color=ff6600><%=intCount%></font>条记录,分<%=intPageCount%>页,当前页<%=Page%>,每页显示<%=intPageSize%>条记录
                          <%
          '计算每一段的开始页
          intStarPage=(Section-2) * intSectionSize + 1
          '前一段
          if Section<=1 then
           response.Write(PrevSectionText & " ")
          else
           response.Write("<a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section-1 & "'>" & PrevSectionText & "</a> ")
          end if
         
          '显示页码列表
          response.Write("第")
          intStarPage=(Section-1) * intSectionSize + 1
          for p=intStarPage to intStarPage + intSectionSize - 1
           if p > intPageCount then exit for
           if p=page then
            response.Write("<strong>[" & p & "]</strong> ")
           else
            response.Write("<a href='" & strPageUrl & "&page=" & p & "&section=" & Section & "'>[" & p & "]</a> ")
           end if
          next
          response.Write("页")
          '后一段
          intStarPage=(Section) * intSectionSize + 1
          if Section>=intSectionCount then
           response.Write(" " & NextSectionText)
          else
           response.Write(" <a href='" & strPageUrl & "&page=" & intStarPage
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值