Modular Paging
1. Query statement block
<%
Get the current file name
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 query Statement"
Rs.Open sql,conn,1,1
rs.pagesize=10 Number of paging records
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>
Sorry, no records match the search criteria! <br>
</div>
2. Display a block of records
<%
Else
Rs. Absolutepage=pagecount
Do as not rs.eof%>
The records displayed
<% i=i+2
Rs.movenext
If I>=rs. PageSize then Exit Do
Loop
' Www.knowsky.com
%>
3.
Paging effect
<table width= "778" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<TR align= "center" >
<% if Rs.pagecount=1 then%>
<TD height= colspan= "4" Class=001><font color= "#000000" > Total [<font color= "#ff0000" ><%= RS.RECORDCOUNT%></FONT>] The message currently displays the first <font color= "red" >1~<%=rs.recordcount%></font> strips </ Font></td>
</tr>
<tr>
<%else%>
<TD width= "19%" height= 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%>
Total [<font color= "#ff0000" ><%=RS.RECORDCOUNT%></FONT>] Information </font></td>
<TD width= "58%" height= 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 ' > Home </font></a>
Response.Write "<a href=" &source& "page=" +cstr (pagecount-1) + "&sortid=" &sortid& "& Typeid= "&typeid&" &qylb= "&qylb&" &title= "&title&" &cityid= "&cityid&" >
<font color= ' 0000BE ' > prev </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 ' > Next </font></a> "
Response.Write "<a href=" &source& "? page=" +cstr (Rs. PageCount) + "&sortid=" &sortid& "&typeid=" &typeid& "&qylb=" &qylb& "&title=" &title& "&cityid=" &cityid& ">
<font color= ' 0000BE ' > Last </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 ' > Last </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 ' > Home </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 ' < %=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 ' > go to <input type= ' text ' name= ' page ' size=2
Page </font>
</td>
<TD width= "10%" align= "center" valign= "Middle" class= "FY" ><input name= "image" type= ' image ' Onclick=check () Value= ' OK ' src= ' http://edu.cnzz.cn/images/button_h.jpg ' ></td>
</form>
<tr>
<TD height= "colspan=" 6 "valign=" bottom "><font color=" #000000 "> </font></td>
</tr>
<% End If%>
<% End If%>
</table>