Classic complete paging program + annotation, applicable to URLs with or without parameters, strongly recommended
Source: Internet
Author: User
<%
'The following program is part of the code of the programming technology article system on my website, focusing on pagination, so other useless code is cleared. You can apply it after modification.
'The complete example of this page program please log on to my website http://www.lshdic.com "technical article" to view
On error resume next 'prevents errors caused by arbitrary URL modification
If request. querystring ("page") = "" then page = 1: else: page = cint (request. querystring ("page") 'to the page number 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, ', which defines the cursor of the record set, the number of records stored on each page, and the current page settings.
Rs. pagesize = 12
Rs. AbsolutePage = page
If err. number <> 0 then 'prevents malicious modification of the website address and database non-recorded errors.
Response. write "exception error"
Response. end
End if
%>
<Base target = '_ blank'> <! -- Make the 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 solves the page and displays the specific number
If rs. eof then exit
Response. write "<tr> <Td>" & I + (page * 13-13) + 1 & ": <A href = '" & rs ("connection ") & "'> & rs (" author ") &" </a> </td> </tr>"
Rs. movenext
Next
%>
<Tr> <Td align = right>
<Base target = '_ top'> <! -- Leave the paging connection out of the new window. The following is the complete program of the perfect paging program that I will focus on. You can modify it as needed. -->
<%
Pagelen = split (request. ServerVariables ("Query_String"), "&") 'get the URL? Parameter URL
If UBound (pagelen) <1 then 'if the URL is xxx. asp? The standard paging method is used for page = 1 or xxx. asp
If page> 1 then response. write "<A href = 'A. asp? Page = 1'> homepage </a> <a href = 'A. asp? Page = "& page-1 &" '> Previous page </a> ": else: response. write" homepage"
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