Program | Pagination today to learn an ASP paging, also take out and share it!!
<%
' The following program is part of the code of the Programming technology article system in my website,
focuses on paging, so other unwanted code is cleared and you can modify it to apply the
' The complete example of the procedure of this page please login to 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 ")" Connection 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
' These definitions are important to define the cursor of the recordset and the number of record bars stored per page and the current page settings
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 in new window-->
<table border=1>
<%
for i=0 to Rs.pagesize-1
' shows the specific data content, i+ (page*13-13) +1, which 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 ("author") & "</a></td></tr>"
Rs.movenext
Next
%>
<TR><TD align=right>
<base target= ' _top ' ><!--make paging connections pop out of the new window, here's the complete procedure for the perfect paging program I'm going to focus on
, you can modify-->
as needed
<%
Pagelen=split (Request. ServerVariables ("Query_string"), "&") ' gets the parameter URL after the URL number
if UBound (pagelen) <1 then ' if the URL is xxx.asp?page=1 or xxx.asp type, use the standard paging method
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 HRE F= ' 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 a xxx.asp?str1= parameter &page=1 the type of the 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= "& I &" ' > "& I &" </a> "
Next
End If ' pagelen (0) equals str1= parameter
' Pagelen (1) equals page=1
rs.close ' Release resources
Set rs=nothing
Set link1=nothing
%>
</table></body></html>