简单分页函数一 常用

2016-02-19 10:11 5 1 收藏

在这个颜值当道,屌丝闪边的时代,拼不过颜值拼内涵,只有知识丰富才能提升一个人的内在气质和修养,所谓人丑就要多学习,今天图老师给大家分享简单分页函数一 常用,希望可以对大家能有小小的帮助。

【 tulaoshi.com - Web开发 】

代码如下:

%
      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
        %
        tr %if (a mod 2)=0 then
      response.write "bgcolor=#ffffff"
      else
      response.write "bgcolor=#f6f6f6"
      end if
      %
          td height="20"div style="text-align:center"%=a%/div/td
          tddiv style="text-align:center"
            %add=rs("add1")
        substring add,4
        %
          /div/td
          td
          a href="displaynews.asp?id=%=rs("id")%" target="_blank"          
         %
        if rs("isred")=True then
        %
        font color="red"
        %title=rs("title")
        substring title,20
        %/font
        %else
        title=rs("title")
        substring title,20
        %
        %
        end if
        %        
        /a/td
          tddiv style="text-align:center"%=rs("cartype")%/div/td
          tddiv style="text-align:center"
              %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
                %
          /div/td
          tddiv style="text-align:center"%=rs("hits")%/div/td
        /tr
        %
      rs.movenext
      if rs.eof then exit for
      next        
      %
      /table
      table width="100%" border="0" cellspacing="0" cellpadding="0"
      tr
        td height="5"/td
      /tr
    /table
     table width="100%" border="0" cellpadding="0" cellspacing="0"
            tr
              td height="20" bgcolor="#f6f6f6"
                  div style="text-align:center"
                    %if rs.pagecount0 then %
              共有%=rs.recordcount%条|当前页%=intpage%/
              %

=rs.pagecount%

              % end if %
              %if intpage1 then%
              a href="%request.ServerVariables("SCRIPT_NAME")%?

page=1"首页/a
              %else%
              首页
              %end if%
              %if first then%
              a href="%request.ServerVariables("SCRIPT_NAME")%?

page=%=intpage-1%"上一页/a
              %else%
              上一页
              %end if%
              %if last and intpagers.pagecount then%
              a href="%request.ServerVariables("SCRIPT_NAME")%?

page=%=intpage+1%"下一页/a
              %else%
              下一页
              %end if%
              %if intpagers.pagecount then%
              a href="%request.ServerVariables("SCRIPT_NAME")%?

page=%=rs.pagecount%"尾页/a
              %else%
              尾页
              %end if%
              转到
              select onChange="location=this.options

[this.selectedIndex].value"
                %for b=1 to rs.pagecount
     if b=intpage then%
                option value="%request.ServerVariables("SCRIPT_NAME")%?page=%=b%" selected

                第%=b%页/option
                % else %
                option value="%request.ServerVariables("SCRIPT_NAME")%?page=%=b%"第%=b%页

                /option
                %end if
     next%
              /select
    /div/td
            /tr
      /table    
/body
%
rs.close
set rs=nothing
conn.close
set conn=nothing
%

来源:https://www.tulaoshi.com/n/20160219/1593711.html

延伸阅读
标签: Web开发
个人会员管理 .closes { font-size:9pt; color:#333333; background-color:#f7f7f7; border:1px solid #CCCCCC;} 个人会员列表 序号 用户名 加入日期 等级 操作 共有 / 条, 当前页 /   [首页] [上一页] ">[首页] &page= ">[上一页] [下一页] [尾页] &page= ">[下一页]  &page= "...
其实在很多时候设计的度还是要把握的,不至于让自己陷入的怪圈中才是最重要的,因为我们还要留出时间还解决其他的很多问题,个人认为适度就可以了,留出一定的空间。也因为万能是不存在的,万物在一定的范畴之内都是合理的,出了范畴可能就没有合理的了。          分页存储过程大致有下列几种 1、&n...
标签: PHP
  每次编写列表性质的页面,几乎都要写上一段分页的程序。最近小阳终于决心一劳永逸——自定义一个分页函数,并保存在“pageft.php”文件里。要用到分页的地方,就直接包含“pageft.php”文件,并调用这个函数就行了。小阳在编写这个函数时,尽量注意了程序的可移植性和易用性,下面就是小阳编写的函数: 好,分页函数已经...
标签: Web开发
代码如下: function HTMLEncode(fString) if not isnull(fString) then fString = replace(fString, "", "") fString = replace(fString, "", "") fString = Replace(fString, CHR(32), " ") fString = Replace(fString, CHR(9),...
标签: ASP
  <% sub Jmail(email) Dim JMail,SendMail Set JMail=Server.CreateObject("JMail.SMTPMail") JMail.Logging=True JMail.Charset="gb2312" JMail.ContentType = "text/html" JMail.ServerAddress=SMTPServer JMail.Sender=SystemEmail JMail.Subject=topic JMail.Body=mailbody JMail.AddRecipient email JMail.Priority...

经验教程

275

收藏

94
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部