asp数字分页函数 实际使用例子。

//调用例子。上面的函数我是封装在pagefunction.asp文件里面的   注明:在引入pagefunction.asp文件之前的也是可以封装成一个固定的文件里面。然后通过引入,调用对应的函数的。

 

//函数是代码重用的最基础的封装。练习多了,代码敲多了,很多基本的功能,都可以逐步封装成为自己的库代码

   <%
               
                  Const MaxPerPage=1
            dim totalPut  
            dim CurrentPage
            dim TotalPages
            dim j
            dim sql
            
            
            
            if Not isempty(SafeRequest("page",1)) then
              currentPage=Cint(SafeRequest("page",1))
            else
              currentPage=1
            end if
            
            i=0
            
            rs.open "select  * from acticle where categoryid=391 order by adddate desc",conn,1,1
   
           if rs.eof and rs.bof then
       
            rs.close
      
           response.write "<center>目前还没有新闻!</center>"
    
            else
              
              totalPut=rs.recordcount
              
              TotalPages=totalPut/MaxPerPage
              
              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,"newslist.asp"
                else
                  if (currentPage-1)*MaxPerPage<totalPut then
                      rs.move  (currentPage-1)*MaxPerPage
                      dim bookmark
                      bookmark=rs.bookmark
                      showContent
                       showpage totalput,MaxPerPage,"newslist.asp"
                 else
                    currentPage=1
                      showContent
                      showpage totalput,MaxPerPage,"newslist.asp"
                end if
              end if
            end if  
              
            sub showContent
                      %>
                      <ul>
              <%
               do while not rs.eof
       
             i=i+1
        %>
                  <li><a href="news.asp?id=<% = rs("id") %>"><%=left(rs("name"),50)%></a><span><% = Year(rs("adddate")) %>.<% = Month(rs("adddate")) %>.<% = day(rs("adddate")) %></span><div class="clear"></div></li>
               
                 <% 
                  if i>=MaxPerPage then Exit Do
        
              rs.movenext
      
            loop
    
            
    
            rs.close
            %>
              </ul>
            <%
           end sub
          %>
         
           
           
        <!--#include file="pagesfunction.asp"-->

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值