模块化分页
1.查询语句块
1
2取得当前文件名
3temp = Split(request.ServerVariables("URL"), "/")
4fy = temp(UBound(temp))
5set rs=server.createobject("adodb.recordset")
6if not isempty(request("page")) then
7pagecount=cint(request("page"))
8else
9pagecount=1
10end if
11sql="select 查询语句"
12rs.open sql,conn,1,1
13rs.pagesize=10 分页记录数
14if pagecount>rs.pagecount or pagecount<=0 then
15pagecount=1
16end if
17if rs.eof and rs.bof then
1<div align="center" class="001"><br/>
2对不起,没有符合搜索条件的记录!<br/>
3</div>
2.显示记录块
1
2else
3rs.AbsolutePage=pagecount
4do while not rs.eof
显示的记录
1 i=i+2
2rs.movenext
3if i>=rs.PageSize then exit do
4loop
5'www.knowsky.com
3.
分页效果
1<table align="center" border="0" cellpadding="0" cellspacing="0" width="778">
2<tr align="center">
if rs.pagecount=1 then
1<td class="001" colspan="4" height="35"><font color="#000000">共有[<font color="#ff0000">```
2=rs.recordcount
3```</font>]条信息 当前显示第 <font color="red">1~```
4=rs.recordcount
5```</font>条</font></td>
6</tr>
7<tr>
else
1<td align="center" class="001" height="35" valign="middle" width="19%"><font color="#000000">
page_start=(pagecount-1)rs.pagesize
if pagecount=1 then page_start=1
page_end=rs.pagesizepagecount
if pagecount*rs.pagesize=>rs.recordcount then page_end=rs.recordcount end if
1共有[<font color="#ff0000">```
2=rs.recordcount
3```</font>]信息</font></td>
4<td align="center" class="fy" height="30" width="58%"><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 ?page='1&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&"' href="&source&">
<font color="0000BE">首页</font></a> "
response.write"<a &cityid="&cityid&" &qylb="&qylb&" &sortid="&sortid&" &title="&title&" &typeid="&typeid&" ?page="+cstr(pagecount-1)+" href="&source&">
<font color="0000BE">上一页</font></a> "
for ipage=qizu to min
if ipage<>pagecount then
response.write"<a &cityid="&cityid&" &qylb="&qylb&" &sortid="&sortid&" &typeid="&typeid&" ?page="+cstr(ipage)+" href="&source&"><font color="0000BE">"+cstr(ipage)+"</font></a> "
else
response.write "<font color="#FF0000">"&ipage&"</font> "
end if
next
response.write"<a &cityid="&cityid&" &qylb="&qylb&" &sortid="&sortid&" &title="&title&" &typeid="&typeid&" ?page="+cstr(pagecount+1)+" href="&source&">
<font color="0000BE">下一页</font></a> "
response.write"<a &cityid="&cityid&" &qylb="&qylb&" &sortid="&sortid&" &title="&title&" &typeid="&typeid&" ?page="+cstr(rs.PageCount)+" href="&source&">
<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 &cityid="&cityid&" &qylb="&qylb&" &sortid="&sortid&" &typeid="&typeid&" ?page="+cstr(ipage)+" href="&source&"><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 &cityid="&cityid&" &qylb="&qylb&" &sortid="&sortid&" &typeid="&typeid&" ?page="+cstr(ipage)+" href="&source&"><font color="0000BE">"+cstr(ipage)+"</font></a> "
else
response.write "<font color="#FF0000">"&ipage&"</font> "
end if
next
response.write "<a &cityid="&cityid&" &qylb="&qylb&" &sortid="&sortid&" &title="&title&" &typeid="&typeid&" ?page="+cstr(rs.PageCount)+" href="&source&">
<font color="0000BE">尾页</font></a>"
end if
if pagecount>rs.PageCount-6 and rs.PageCount>10 then
response.write "<a ?page='1&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&"' href="&source&">
<font color="0000BE">首页</font></a> "
for ipage=rs.PageCount-9 to rs.PageCount
if ipage<>pagecount then
response.write"<a &cityid="&cityid&" &qylb="&qylb&" &sortid="&sortid&" &typeid="&typeid&" ?page="+cstr(ipage)+" href="&source&"><font color="0000BE">"+cstr(ipage)+"</font></a> "
else
response.write "<font color="#FF0000">"&ipage&"</font> "
end if
next
end if
1</font></td><form =fy="" ```="" action="```" form="" method="Post" name="go2to">
2<td align="center" class="fy" valign="middle" width="13%">
3<input name="sortid" type="hidden" value="```
4=sortid
5```"/><input name="typeid" type="hidden" value="```
6=typeid
7```"/><input name="qylb" type="hidden" value="```
8=qylb
9```"/><input name="title" type="hidden" value="```
10title
11```"/><input name="cityid" type="hidden" value="```
12=cityid
13```"/><font color="000064"> 转到第<input maxlength="3" name="page" size="2" type="text"/>
14页</font>
15</td>
16<td align="center" class="fy" valign="middle" width="10%"><input name="image" onclick="check()" src="../images/button_h.jpg" type="image" value="确 定"/></td>
17</form>
18<tr>
19<td colspan="6" height="20" valign="bottom"><font color="#000000"> </font></td>
20</tr>
end if
end if
1</tr></table>