网站首页站长博客下载中心域名交易站长论坛域名主机免费电邮免费域名中文排行排名查询站长书库书籍教程下载
设为首页
加入收藏
总编信箱
投稿或申请专栏请先 [登 陆]
学院首页 网络编程 网页设计 图形图象 数 据 库 服 务 器 网络媒体 网络安全 个人专栏 站长CLUB 业界新闻 信息公告
 当前位置:首页 >> 网络编程 >> ASP专区 >> 正文
公告通知
返回上级列表
资料搜索
相关文章
 ASP从数据库中获取文件
ASP+JavaScript的完整的日历使用
ASP+JavaScript的完整的日历使用
一个asp函数, 解决SQL Injectio
在ASP中通过oo4o连接Oracle数据库
创建一个ASP通用分页类 
asp下用OracleInProcServer完成对
ASP中Request对象获取客户端数据
ASP技术访问WEB数据库
ASP中从数据库读取二进制文件数据
asp模块化分页
[ 来源:CSDN | 作者:未知 | 时间:2006-4-13 7:02:44 | 浏览:人次 ]
收藏到新浪ViVi 收藏到365KEY 收藏到我摘  字号选择〖    〗/ 双击滚屏 单击停止  
 

模块化分页

1.查询语句块

<%
取得当前文件名
temp = Split(request.ServerVariables("URL"), "/")
fy = temp(UBound(temp))
set rs=server.createobject("adodb.recordset")
if not isempty(request("page")) then  
pagecount=cint(request("page"))  
else  
pagecount=1  
end if
sql="select  查询语句"
rs.open sql,conn,1,1
rs.pagesize=10  分页记录数
if pagecount>rs.pagecount or pagecount<=0 then             
pagecount=1             
end if            
if rs.eof and rs.bof then%>

<div align="center" class="001"><br>
对不起,没有符合搜索条件的记录!<br>
</div>

2.显示记录块

<%
else
rs.AbsolutePage=pagecount
do while not rs.eof %>

显示的记录

<% i=i+2                                                                                                 
rs.movenext                                                                                                 
if i>=rs.PageSize then exit do
loop                                                                   
%>

3.
分页效果
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr align="center">
    <% if rs.pagecount=1 then %>
    <td height="35" colspan="4" class=001><font color="#000000">共有[<font color="#ff0000"><%=rs.recordcount%></font>]条信息 当前显示第 <font color="red">1~<%=rs.recordcount%></font>条</font></td>
  </tr>
  <tr>
    <%else%>
    <td width="19%" height="35" align="center" valign="middle" class=001><font color="#000000">
      <% page_start=(pagecount-1)*rs.pagesize
            if pagecount=1 then page_start=1
      page_end=rs.pagesize*pagecount
      if pagecount*rs.pagesize=>rs.recordcount then page_end=rs.recordcount end if%>
      共有[<font color="#ff0000"><%=rs.recordcount%></font>]信息</font></td>
    <td width="58%" height="30" align="center" class="fy"><font color="#000000">
          <%
    if pagecount>5 and pagecount< rs.PageCount-5 and rs.pagecount>10 then
    qizu=pagecount-4
    min=pagecount+5
    response.write "<a href="&source&"?page=1&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&"><font color='0000BE'>首页</font></a>&nbsp;"
    response.write "<a href="&source&"?page="+cstr(pagecount-1)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&"><font color='0000BE'>上一页</font></a>&nbsp;"                                                    
    for ipage=qizu to min
             if ipage<>pagecount then
             response.write "<a href="&source&"?page="+cstr(ipage)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&cityid="&cityid&"><font color='0000BE'>"+cstr(ipage)+"</font></a>&nbsp;"
             else
             response.write "<font color='#FF0000'>"&ipage&"</font> "                                               
             end if
    next
    response.write "<a href="&source&"?page="+cstr(pagecount+1)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&"><font color='0000BE'>下一页</font></a>&nbsp;"
    response.write "<a href="&source&"?page="+cstr(rs.PageCount)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&"><font color='0000BE'>尾页</font></a>"
    end if
    if rs.PageCount<11 then
    for ipage=1 to rs.PageCount
             if ipage<>pagecount then
             response.write "<a href="&source&"?page="+cstr(ipage)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&cityid="&cityid&"><font color='0000BE'>"+cstr(ipage)+"</font></a>&nbsp;"
             else
             response.write "<font color='#FF0000'>"&ipage&"</font> "                                               
             end if
    next
    end if
    if pagecount < 6 and rs.PageCount>10 then
    for ipage=1 to 10
             if ipage<>pagecount then
             response.write "<a href="&source&"?page="+cstr(ipage)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&cityid="&cityid&"><font color='0000BE'>"+cstr(ipage)+"</font></a>&nbsp;"
             else
             response.write "<font color='#FF0000'>"&ipage&"</font> "                                               
             end if
    next
    response.write "<a href="&source&"?page="+cstr(rs.PageCount)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&"><font color='0000BE'>尾页</font></a>"
    end if
    if pagecount>rs.PageCount-6 and rs.PageCount>10 then
    response.write "<a href="&source&"?page=1&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&"><font color='0000BE'>首页</font></a>&nbsp;"  
    for ipage=rs.PageCount-9 to rs.PageCount
             if ipage<>pagecount then
             response.write "<a href="&source&"?page="+cstr(ipage)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&cityid="&cityid&"><font color='0000BE'>"+cstr(ipage)+"</font></a>&nbsp;"
             else
             response.write "<font color='#FF0000'>"&ipage&"</font> "                                               
             end if
    next
    end if
             %>
    </font></td><form name=go2to form method=Post action=<%=fy%>> 
    <td width="13%" align="center" valign="middle" class="fy">                                         
   <input type='hidden' name='sortid' value="<%=sortid%>"><input type='hidden' name='typeid' value="<%=typeid%>"><input type='hidden' name='qylb' value="<%=qylb%>"><input type='hidden' name='title' value="<%title%>"><input type='hidden' name='cityid' value="<%=cityid%>"><font color='000064'> 转到第<input type='text' name='page' size=2 maxLength=3>
   页</font>                              
   </td>
    <td width="10%" align="center" valign="middle" class="fy"><input name="image" type='image' onClick=check() value='确 定' src='../images/button_h.jpg'></td>
    </form>
  <tr>
    <td height="20" colspan="6" valign="bottom"><font color="#000000">&nbsp; </font></td>
  </tr>
  <% end if %>
  <% end if %>
</table>



[发送给好友]  [打印本页]  [关闭窗口]  [返回顶部]   转载请注明来源:http://edu.chinaz.com   
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
栏目编辑: 设计风 责任编辑: keke
原始作者: 未知 录入时间: 2006-4-13 7:02:44
信息来源: CSDN 投稿信箱: Edu#chinaz.com
设为首页 - 加入收藏 - 关于我们 - 广告服务 - 版权申明 - 友情链接 - 联系方式 - 总编信箱 - 会员投稿