选择显示字体大小

2栏分页显示(附显示的形式前页,后页)


  显示形式:
         id1     name    id2   name
         1       juliet   2     palyboy
         3       baby     4     tom
         5       lena     6      jery
>>首页 前页 后页 尾页  页数:1/4  6条/页   总记录数:25条
代码:
<!--page1.asp-->
<!--#include file=&quot;conn.asp&quot;-->
<html>
<body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;>
<table width=&quot;60%&quot; border=&quot;1&quot; align=&quot;center&quot;>
<%
    dim rs
    dim sql
    msg_per_page    =    4                                                        '定义每页显示记录条数
    set rs    =    server.createobject(&quot;adodb.recordset&quot;)
    sql = &quot;select * from page order by id&quot;                                      '改成你自己的sql语句
    rs.cursorlocation    =    3                                                    '使用客户端游标,可以使效率提高
    
    rs.pagesize    =    msg_per_page                                                '定义分页记录集每页显示记录数
    rs.open sql,conn,0,1                                                        

    if err.number<>0 then                                                        '错误处理
        response.write &quot;数据库操作失败:&quot; & err.description
        err.clear
    else
        if not (rs.eof and rs.bof) then                                            '检测记录集是否为空
            totalrec    =    rs.recordcount                                        'totalrec:总记录条数
            if rs.recordcount mod msg_per_page    =    0 then                        '计算总页数,recordcount:数据的总记录数
                n    =    rs.recordcount\msg_per_page                                'n:总页数
            else                                                                
                n    =    rs.recordcount\msg_per_page+1                        
            end if                                                                

            currentpage    =    request(&quot;page&quot;)                                        'currentpage:当前页
            if currentpage <> &quot;&quot; then
                currentpage =  cint(currentpage)
                if currentpage < 1 then  
                    currentpage = 1
                end if  
                if err.number <> 0 then
                    err.clear
                    currentpage    =    1
                end if
            else
                currentpage = 1
            end if                                                                
            if currentpage*msg_per_page > totalrec and not((currentpage-1)*msg_per_page < totalrec)then
                currentpage=1
            end if
            rs.absolutepage    =    currentpage                                    'absolutepage:设置指针指向某页开头
            rowcount        =    rs.pagesize                                    'pagesize:设置每一页的数据记录数
            
            dim i
            dim k
%>
        <tr align=&quot;center&quot; valign=&quot;middle&quot;>
            <td width=&quot;25%&quot;>id1</td>
            <td width=&quot;25%&quot;>name1</td>
            <td width=&quot;25%&quot;>id2</td>
            <td width=&quot;25%&quot;>name2</td>
        </tr>
        <%do while not rs.eof and rowcount > 0%>
        <tr align=&quot;center&quot; valign=&quot;middle&quot;>
            <td width=&quot;25%&quot;><%=rs(&quot;id&quot;)%></td>
            <td width=&quot;25%&quot;><%=rs(&quot;testname&quot;)%></td>
            <td>
                <%
                    rowcount=rowcount-1
                    rs.movenext
                    if not rs.eof then
                %>
                        <%=rs(&quot;id&quot;)%>
            </td>
            <td width=&quot;25%&quot;><%=rs(&quot;testname&quot;)%></td>
        </tr>
<%
                        rowcount=rowcount-1
                        rs.movenext
                    else
                        response.write &quot;&nbsp;</td><td>&nbsp;</td></tr>&quot;
                    end if
          loop
        end if
    end if
    rs.close
    set rs=nothing
%>
  
</table>
<table border=&quot;0&quot; align=&quot;center&quot;>
  <tr>
    <td align=&quot;center&quot; valign=&quot;middle&quot;>
      <%call listpages()%>
    </td>
  </tr>
</table>
</body>
</html>
<%
    sub listpages()                                                                
        if n <= 1 then exit sub                                                    
%>
        <p><span class=smallfont>&gt;&gt;
        <%if currentpage    =    1 then%>
            <font color=darkgray face=&quot;arial&quot; >top previous</font>
        <%else%>                                                                    
            <font color=black face=&quot;arial&quot;><a href=&quot;<%=request.servervariables(&quot;script_name&quot;)%>?page=1&quot;>top</font></a>
            &nbsp<a href=&quot;<%=request.servervariables(&quot;script_name&quot;)%>?page=<%=currentpage-1%>&quot;>
            <font color=black face=&quot;arial&quot; >previous</a></font>
        <%end if%>
        <%if currentpage    =    n then%>                                                    
            <font color=darkgray face=&quot;arial&quot; >next bottom</font>
        <%else%>                                                                    
            <font color=black face=&quot;arial&quot; ><a href=&quot;<%=request.servervariables(&quot;script_name&quot;)%>?page=<%=currentpage+1%>&quot;>next</a>
            &nbsp<a href=&quot;<%=request.servervariables(&quot;script_name&quot;)%>?page=<%=n%>&quot;>bottom</a></font>
        <%end if%>
        <font color=black face=&quot;arial&quot; >
        &nbsp page:<%=currentpage%>/<%=n%>pages&nbsp&nbsp<%=msg_per_page%>notes/page &nbsp total:<%=totalrec%>notes</font></span></p>
  <%end sub%>


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons