Programs | paging | Pagination This is just an ASP tip class, it is suitable for each of the different file names call this function, but there are prerequisites, let's take a closer look at the story.
The following section is the basic page-splitting code:
<% sql = "Select ... ..... ........... The SQL statement is omitted
Set rs=server.createobject ("ADODB. RECORDSET ")
Rs. Open SQL, Conn, 1, 1
If not rs.eof then
Pages = 30 ' defines the number of records to display per page
rs.pagesize = Pages ' defines the number of records displayed per page
Allpages = Rs.pagecount ' Calculate how many pages can be divided altogether
page = request.querystring ("page") ' number of pages passed through the browser
' If statement belongs to the basic error handling
If IsEmpty (page) or Cint (page) 1 Then
page = 1
ElseIf Cint (page) > Allpages Then
page = Allpages
End If
Rs. AbsolutePage = page
Do, not rs.eof and pages 0%>
Here's what you want to do ..... ......
<% pages = pages-1
Rs. MoveNext
Loop
Else
Response.Write ("The database is not content!") ")
End If
Rs. Close
Set rs = Nothing%>
The system has been paging the data, and here's a look at the key issues of this discussion the definition of paging function
<% SUB Pageurl (PURL)
Dim Eurl
txts = Request.ServerVariables ("URL")
Txts = Left (Txts,instrrev (txts, "/", Len (txts))-1)
Eurl = "http://"; & Request.ServerVariables ("SERVER_NAME") & Txts
For I =1 to Allpages
txt = ""
txt = "<strong>"
txt = txt & "<a Href=" & Eurl & PUrl & "page=" &i & ">"
If i = Cint (Page) Then txt = txt & "<font color= ' bb0000 '"
txt = txt & (i)
If i = Cint (Page) Then txt = txt & "</font>"
txt = txt & "</a> ∥ </strong>"
Response.Write (TXT)
Next
End Sub%>
Save the page function code copy as an ASP file, and use include in the page you want to use to bring in the call ("/the filename you called?"). OK, like the one on my news page is called <%call ("/news.asp?") %>
There's a limit to what we've been up to. That is, in the first code, in addition to the SQL query content and output can be changed, the other declared Recordset object, page, pages, allpages these variables can not be changed, otherwise it will not run ~ In fact, this program is irrelevant, the most important is , the paging function can be invoked in any ASP leaf. Pagination do not beautiful, experts can modify the changes, can be sent to me, I will be responsible for you to publish it!