asp分页代码

 <%'开始分页
    Const MaxPerPage=25
       dim totalPut  
       dim CurrentPage
       dim TotalPages
       dim j
       dim sql
        if Not isempty(request("page")) then
          currentPage=Cint(request("page"))
       else
          currentPage=1
       end if
   set rs=server.createobject("adodb.recordset")
      rs.open "*",conn,1,1
      if rs.eof And rs.bof then
           Response.Write "<p align='center' class='in'> 您还没有添加活动!</p>"
       else
       totalPut=rs.recordcount

          if currentpage<1 then
              currentpage=1
          end if

          if (currentpage-1)*MaxPerPage>totalput then
         if (totalPut mod MaxPerPage)=0 then
           currentpage= totalPut / MaxPerPage
         else
            currentpage= totalPut / MaxPerPage + 1
         end if
          end if

           if currentPage=1 then
               showContent
               showpage totalput,MaxPerPage,"pageList.asp"
           else
              if (currentPage-1)*MaxPerPage<totalPut then
                rs.move  (currentPage-1)*MaxPerPage
                dim bookmark
                bookmark=rs.bookmark
                showContent
                 showpage totalput,MaxPerPage,"这块是你当前页面的名称,比如page.asp"
            else
             currentPage=1
                showContent
                showpage totalput,MaxPerPage,"这块是你当前页面的名称,比如page.asp"
           end if
        end if
              end if

       sub showContent
          dim i
       i=0

   %>
    <table class="tableBorder" width="98%" border="0" align="center" cellpadding="3" cellspacing="1" style=" margin-left:20px;">
                <%do while not rs.eof

    %>
                <tr>
<td style="PADDING-LEFT: 6px;">&#8226;&nbsp;<a href="content.asp?id=<%=rs("*")%>" target=_blank style="color:#666666"><%=left(trim(rs("*")),20)%></a></td>
                  <td align="center" style="PADDING-LEFT: 6px;color:#999999"><%=rs("*")%></td>
                </tr> <tr>
                    <td height="1" background="images/img_msjg_62.gif"></td>
                    <td background="images/img_msjg_62.gif"></td>
                  </tr>
                <%i=i+1
   if i>=MaxPerPage then Exit Do
   rs.movenext
    loop
    rs.close
    set rs=nothing%>
              </table>
              <% 
    End Sub  
 
    Function showpage(totalnumber,maxperpage,filename) 
      Dim n
      
    If totalnumber Mod maxperpage=0 Then 
     n= totalnumber / maxperpage 
    Else
     n= totalnumber / maxperpage+1 
    End If
    
    Response.Write "<form method=Post action="&filename&">" 
    Response.Write "<p align='center' class='in'> " 
    If CurrentPage<2 Then 
     Response.Write "<font class='in'>首页 上一页</font> " 
    Else 
     Response.Write "<a href="&filename&"?page=1&classid="&classid&" class='in'>首页</a> " 
     Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&classid="&classid&" class='in'>上一页</a> " 
    End If
    
    If n-currentpage<1 Then 
     Response.Write "<font class='in'>下一页 尾页</font>" 
    Else 
     Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&classid="&classid&" class='in'>" 
     Response.Write "下一页</a> <a href="&filename&"?page="&n&"&classid="&classid&" class='in'>尾页</a>" 
    End If 
     Response.Write "<font class='in'> 页次:</font><font class='in'>"&CurrentPage&"</font><font class='in'>/"&n&"页</font> " 
     Response.Write "<font class='in'> 共有"&totalnumber&"条文章 "
     Response.Write "<font class='in'>转到:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="&currentpage&">" 
     Response.Write "&nbsp;<input type='submit' value='GO' name='cndok'></form>" 
    End Function 
   %>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值