asp模块化分页制作详解
2008-02-23 05:29:30来源:互联网 阅读 ()
模块化分页
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&">
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash