热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

简单分页函数一常用

简单分页函数一常用
代码如下:

<%
      page=trim(request("page"))
      maxperpage=40
      first=true
      last=true
      dim rs
      set rs=server.CreateObject("adodb.recordset")
      sql="select id,title,add1,cartype,isred,enterdate,hits from newnews where classtype=0 and pass=1 order by id desc"
rs.open sql,conn,1,1
        rs.pagesize=maxperpage
        totalpage=rs.pagecount
        if len(page)=0 then
        intpage=1
        first=false
        else
            if cint(page)<=1 then
            intpage=1
            first=false
            else
                if cint(page)>=rs.pagecount then
                intpage=rs.pagecount
                last=false
                else
                intpage=cint(page)
                end if
            end if
        end if            
        if not rs.eof then
        rs.absolutepage=intpage
        end if
        for a=1 to maxperpage
        if rs.eof then exit for
        %>
              response.write "bgcolor=#ffffff"
      else
      response.write "bgcolor=#f6f6f6"
      end if
      %>>
          <%=a%>

          
            <%add=rs("add1")
        substring add,4
        %>
          

          
          " target="_blank">          
         <%
        if rs("isred")=True then
        %>
        
        <%title=rs("title")
        substring title,20
        %>
        <%else
        title=rs("title")
        substring title,20
        %>
        <%
        end if
        %>        
        
          <%=rs("cartype")%>

          
              <%thetime=rs("enterdate")
                    themon=datepart("m",thetime)
                    if len(themon)<2 then themon="0"&themon
                    theday=datepart("d",thetime)
                    if len(theday)<2 then theday="0"&theday
                    ther=themon&"-"&theday
                    response.write ther
                %>
          

          <%=rs("hits")%>
        
        <%
      rs.movenext
      if rs.eof then exit for
      next        
      %>
      
      
      
        
      
    
     
            
              
                  
                    <%if rs.pagecount>0 then %>
              共有<%=rs.recordcount%>条|当前页<%=intpage%>/
              <%

=rs.pagecount%>

              <% end if %>
              <%if intpage>1 then%>
              ?

page=1">首页
              <%else%>
              首页
              <%end if%>
              <%if first then%>
              ?

page=<%=intpage-1%>">上一页
              <%else%>
              上一页
              <%end if%>
              <%if last and intpage
              ?

page=<%=intpage+1%>">下一页
              <%else%>
              下一页
              <%end if%>
              <%if intpage
              ?

page=<%=rs.pagecount%>">尾页
              <%else%>
              尾页
              <%end if%>
              转到
              
[this.selectedIndex].value">
                <%for b=1 to rs.pagecount
     if b=intpage then%>
                ?page=<%=b%>" selected>

                第<%=b%>页
                <% else %>
                ?page=<%=b%>">第<%=b%>页

                
                <%end if
     next%>
              
    
            
           <%
rs.close
set rs=nothing
conn.close
set cOnn=nothing
%>

推荐阅读
author-avatar
我才是陈墨_773
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有