asp模块化分页源码
来源:CSDN 发布时间:2008-04-13 07:02:00
标签:分页,模块,asp
模块化分页
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>
0
投稿
猜你喜欢
- 效果图:作用:将页面中的电话号码生成图片格式。<%Public Sub Com_CreatValidCode(pT
- 前言:最近某个时间开始,特别留意了一下Web标准中柱状图,也就是英文中的bar graph的实现。虽然实现方法各异,效果不尽相同,但是总体来
- WAP站点,这似乎是一个有点落伍的东西。在诞生之初,它很简陋,只能通过一个叫WML的标记语言来搭建没有任何美感的文字+链接页面。而今,绝大部
- 经常在网站上看到诸如www.abc.com/?news或者www.abc.com/?id=123这样的网址,一开始觉得很神秘,其实现在看多了
- 定义: 何为触发器?在SQL Server里面也就是对某一个表的一定的操作,触发某种条件,从而执行的一段程序。触发器是一个特殊的存储过程。
- 对于使用虚拟主机的站长朋友,我们可能不知道该服务器是否安装了某种我们需要的组件。这时我们可以使用下面的代码来判断。该函数功能:检查是否存在系
- 通过 CSS transform (firefox文档, safari文档)属性. 无所不能的css也开始玩起3D效果了。在配合 CSS t
- 以下摘录自 oreilly.JavaScript.The.Definitive.Guide.5th.Edition.Aug.200
- 用户登录验证脚本,Chkpwd.asp<% '=======用户登录验证脚本======= '如果尚未定义Passed
- 复制代码CREATE FUNCTION fGetStrBySplit ( @Source VARCHAR(max), @Index INT,
- 长期以来一直以为iframe跟div一样都是块级元素,直到今天在一个群中看到一位朋友问到iframe怎么居中的时候,测试了下发现原来我一直对
- 在我们制作网页的时候会经常碰到一些需求,如果不知道方法,说不定会困扰我们半天。其实实现它们都很简单,下
- 自从jQuery搞出特性侦探这东东,西方从来没有如此狂热研究浏览器。在以前javascript与DOM遍地是bug,美工主宰前端的年代,人们
- 联合结果集 新建临时工数据表 代码如下:CREATE TABLE T_TempEmployee (FIdCardNumber VARCHAR
- 如何验证信用卡是否可用,合法? 核实信用卡的真伪是一件麻烦的事儿,看看下面的代码,也许会给你帮上忙:<Script 
- 最近看到一个词叫css reset。什么叫做css reset呢?我理解为重置css,也就是重置默认样式。我在HTML下的默认样式中讲到,一
- 国外纷纷传言IE8将是Internet Explorer的最后一个版本,这个猜测来源于Microsoft的CEO Steve
- 代码如下:CREATE PROCEDURE page @tblName varchar(255), -- 表名 @strGetF
- 熟悉css的开发者一定知道图像替换技术,也深知它的意义,Dave Shea 曾在他的一篇文章对此做了详细的总结,参看 Dave Shea’s
- 代码如下:DECLARE @c INT DECLARE @c2 INT SELECT @c = COUNT(1) FROM dbo.Spli