ASP Modular Paging

Source: Internet
Author: User
Tags min sql query
Paging 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
%>

3.
Paging effect
<table width= "778" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
&LT;TR align= "center" >
<% if Rs.pagecount=1 then%>
&LT;TD height= colspan= "4" Class=001><font color= "#000000" > Total [<font color= "#ff0000" ><%= RS.RECORDCOUNT%&GT;&LT;/FONT&GT] The message currently displays the first <font color= "red" >1~<%=rs.recordcount%></font> strips </ Font></td>
</tr>
<tr>
<%else%>
&LT;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" &GT;&LT;%=RS.RECORDCOUNT%&GT;&LT;/FONT&GT;] Information </font></td>
&LT;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 <



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.