asp模块化分页源码
来源:CSDN 时间:2008-04-13 07:02:00
模块化分页
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> "
response.write "<a href="&source&"?page="+cstr(pagecount-1)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&"><font color='0000BE'>上一页</font></a> "
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> "
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> "
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> "
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> "
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> "
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> "
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='http://edu.chinaz.com/Get/Program/images/button_h.jpg'></td>
</form>
<tr>
<td height="20" colspan="6" valign="bottom"><font color="#000000"> </font></td>
</tr>
<% end if %>
<% end if %>
</table>
标签:分页,模块,asp
0
投稿
猜你喜欢
sqlserver 数据库压缩与数据库日志(ldf)压缩方法分享
2012-01-05 18:57:19
IE10增强对HTML5和CSS3的支持
2011-09-16 20:16:28
python抽象基类用法实例分析
2021-03-04 11:06:25
Python入门教程(三十三)Python的字符串格式化
2023-04-03 11:58:17
原生JS实现匀速图片轮播动画
2024-06-07 15:28:15
交互设计实用指南系列(8)—深广度平衡
2010-02-01 12:59:00
python有证书的加密解密实现方法
2023-02-10 08:07:30
python如何实现excel数据添加到mongodb
2023-05-05 17:23:18
python selenium 获取标签的属性值、内容、状态方法
2021-03-12 23:02:46
C# 操作 access 数据库的实例代码
2024-01-28 15:05:11
python中子类调用父类函数的方法示例
2023-12-30 14:17:03
python argparser的具体使用
2023-07-13 09:25:36
Oracle中pivot函数图文实例详解
2023-07-12 22:13:49
Python通用循环的构造方法实例分析
2022-03-30 00:03:56
MYSQL表优化方法小结 讲的挺全面
2024-01-25 14:20:00
关于点击区域
2009-07-24 13:08:00
分享5个方便好用的Python自动化脚本
2021-04-12 08:27:32
详解SQL中Group By的用法
2024-01-28 14:01:32
数据库自动化技术弥补数据库DBA短缺难题
2009-02-04 16:53:00
[译]图片优化 第五章:AlphaImageLoader
2010-08-29 18:39:00