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
‘’www.knowsky.com
%>
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=‘’../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中如何限制重复提交同一表单
- · 在web.config中添加连接字符串
- · 想试着做一个简单的读取RSS新闻的页面
- · 把数据库连接信息写在web.config文件里(vs.net2003)
- · 一个类msn space的case manage system
- · ASP判断文件地址是否有效!
- · 用Asp隐藏文件路径实现防盗链
- · Asp:Cookies应用指南,详细代码及教程
- · asp编程:召开自己的新闻发布会
- · 如何实现真正的动态包含
- · 用静态URL显示动态网页
- · 页顶导航条示例
- · 简单析取html文件实例
- · 树目录菜单的制作
- · 用ASP创建Word文件
- · ASP翻页的实现方法
- · 用ASP建立网站地图
- · 获得ASP的中文日期字符串
- · 利用索引服务和ASP建立面向整个网站搜索程序
- · ASP+中不再依赖Cookie的设定方法
- · 负载平衡环境下的SESSION管理
- · ASP应用中数据库记录的选取与过滤
- · ASP的多条件动态查询
- · 优化ASP应用程序技巧四则
- · ASP中ActiveX控件的内嵌及调用
- · 在win2003上用cdo代替CDONTS发邮件
- · Freetextbox的使用
- · asp提供在线文章翻译的功能
- · 关于Request
- · 基于B/S下的IC智能卡的安全问题
- · ASP小偷偷取地址并生成html
- · 求助关于远程访问ACCESS数据库的问题
- · Forms验证中的roles
- · 一个比较精辟的索引文章
- · T-SQL: 17 个与日期时间相关的自定义函数(UDF)
- · 限制某段IP地址
- · 调用winrar压缩文件夹
- · ASP做的剪包锤游戏
