This is just an ASP little skill. Although it is suitable for calling this function in different file names, it is also a prerequisite. Let's take a closer look at the original principles.
The following section shows the basic page Code :
<% SQL = "select ........................ SQL statement 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 displayed per page
Rs. pagesize = pages defines the number of records displayed on each page
Allpages = Rs. pagecount calculate the total number of pages that can be divided.
Page = request. querystring ("page ")'
'If statement is a basic troubleshooting method
If isempty (PAGE) or CINT (PAGE) <1 then
Page = 1
Elseif CINT (PAGE)> allpages then
Page = allpages
End if
Rs. absolutepage = page
Do while not Rs. EOF and pages> 0%>
Output the content you want ..................
<% Pages = pages-1
Rs. movenext
Loop
Else
Response. Write ("the database has no content! ")
End if
Rs. Close
Set rs = nothing %>
The system has already paged the data. Let's take a look at the definition of the paging function, which is a key issue discussed this time.
<% Sub pageurl (purl)
Dim eurl
Txts = request. servervariables ("url ")
Txts = left (txts, limit Rev (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 = 'bb000000'>"
TXT = TXT & (I)
If I = CINT (PAGE) Then TXT = TXT & "</font>"
TXT = TXT & "</a> upload </strong>"
Response. Write (txt)
Next
End sub %>
Copy the code of the paging function above into an ASP file, and use include in the page to introduce the file name called by him as long as call ("/Your called file name? ") It's OK. For example, if you want to call the service on my news page, it is <% call ("/news. asp? ") %>
what we just mentioned is restricted. That is to say, in the first code, except for SQL query content and output content, other declared record set objects, pages, pages, all the variables in allpages cannot be changed; otherwise, they cannot be run ~ In fact, this Program is irrelevant. The most important thing is that this paging function can be called in any ASP leaf.