Classic pagination Complete program + Comment

Source: Internet
Author: User
Tags modify prev
<%
' The following program is part of the programming technology article system in my website that focuses on paging, so other unwanted code is cleared and you can modify the application
' The complete example of this page program, please visit my website http://www.lshdic.com "technical article" column to view
On Error Resume Next ' Prevents users from arbitrarily modifying URLs to cause errors
If Request.QueryString ("page") = "" Then Page=1:else:page=cint (request.querystring ("page")) ' to the number of pages in the URL page=?

Set Link1=server.createobject ("ADODB. Connection ")" Connect to the database
Link1.open "Provider=Microsoft.Jet.OLEDB.4.0; Data source= "& Server.MapPath (" Database 1.mdb ")
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open "SELECT * FROM Table 1", link1,1,1 ' This sentence defines the cursor of the recordset and the number of record bars stored per page and the current page setting, which is important
Rs.pagesize=12
Rs. Absolutepage=page
If Err.number<>0 then ' prevents users from maliciously modifying the URL, and the database has no logged errors
Response.Write "Unexpected Error"
Response.End
End If
%>
<base target= ' _blank ' ><!--make content pop up in a new window-->
<table border=1>
<%
For i=0 to Rs.pagesize-1 ' shows the specific data content, i+ (PAGE*13-13) +1 This resolution shows the specific number after pagination
If Rs.eof then exit for
Response.Write "<tr><Td>" & i+ (PAGE*13-13) +1 & ": <a href= '" & RS ("Connection") & "' > & RS (" Person ") &" </a></td></tr> "
Rs.movenext
Next
%>
&LT;TR&GT;&LT;TD align=right>
<base target= ' _top ' ><!--make the paging connection not pop in the new window, here is the complete program for the perfect paging program that I want to focus on, you can modify the--> as needed
<%
Pagelen=split (Request. ServerVariables ("Query_string"), "&") ' Get the parameter URL after the URL number
If UBound (pagelen) <1 then ' the standard paging method if the URL is xxx.asp?page=1 or xxx.asp type
If Page>1 then Response.Write "<a href= ' a.asp?page=1 ' > Home </a> <a href= ' a.asp?page= ' & page-1 & ' ' > Prev </a> ': else:response.write "First Prev"
If Page<rs.pagecount then Response.Write "<a href= ' a.asp?page=" & page+1 & "' > Next page </a> <a href= ' A . asp?page= "& Rs.pagecount &" ' > Last </a> ": Else:response.write" Next Last "
For I=1 to Rs.pagecount
If I=page then Response.Write I & ": Else:response.write" <a href= ' a.asp?page= "& I &" ' > "& I ; "</a>"
Next

Else ' If the URL is the type of the xxx.asp?str1= parameter &page=1 other paging method

If Page>1 then Response.Write "<a href= ' a.asp?" & Pagelen (0) & "&page=1 ' > Home </a> <a href= ' A." ASP? "& Pagelen (0) &" &page= "& page-1 &" ' > Page </a> ": Else:response.write" First Prev "
If Page<rs.pagecount then Response.Write "<a href= ' a.asp?" & Pagelen (0) & "&page=" & page+1 & "' > next page </a> <a href= ' a.asp? & Pagelen (0) & "&page=" & Rs.pagecount & "' > Last </a>": El Se:response.write "Next Page last"
For I=1 to Rs.pagecount
If I=page then Response.Write I & ": Else:response.write" <a href= ' a.asp? "& Pagelen (0) &" &page= "&am P I & "' >" & I & "</a>"
Next
End If ' Pagelen (0) equals str1= parameter
' Pagelen (1) equals page=1
Rs.close ' Releasing resources
Set rs=nothing
Set link1=nothing
%>
</table></body>

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.