Pagination about ASP paging problem, for beginners is a more important issue, but also the most extensive use of the Web site technology, I will summarize my summary of a little experience to everyone (bad writing, please advise)
1. Principle: ASP Paging in fact, the record in the database is divided into several segments "split-screen display"
, why is called "split-screen display" display, because in fact, the original page displayed only 1 pages, through the control of the database display, to refresh the display content of the page (perhaps some friends will be misunderstood for the dynamic generation of several pages to show, oh, I just learned when it is so thought)
2. Several functions used
Rs.pagesize---> Define the number of bars on a page showing records
Total number of Rs.recordcount---> Statistic records
Rs.pagecount----> Total pages of statistics
These functions believe that everyone will soon understand the consciousness, but there is a function its use may be difficult to understand
Rs.absolutepage---> Move the database pointer to the first record of the data record that you want to display on the current page, such as a database with 20 records, we have 10 records to display a page, when your page is 2 o'clock, By using Rs.absolutepage, move the pointer to the 11th record, and so on ....
3. We understand the principle after we began to look at a section of the program, some of the files I will not be explained in detail, do not understand the friend can see first
Http://www.2yup.com/asp/forum/branch.asp?pid=55084&pn=5
--------------------------------------------------
<!--#include file=conn1.asp-->
<%
Dim m,n
Set Rs=server. CreateObject ("Adodb.recordset")
Sqlstr= "SELECT * from Message ORDER BY time Desc"
Rs.Open sqlstr,conn,3,3
Rs.pagesize=10 ' defines the number of records displayed on one page
Tatalrecord=rs.recordcount ' Get the total number of records
Tatalpages=rs.pagecount ' Get the number of paging
Rs.movefirst
----------------------------
Nowpage=request ("page") ' Gets the current number of pages with request, noting that page is a variable of its own definition, not a function
--------------------------
If nowpage& "x" = "x" then "handles the case where the page number is empty
Nowpage=1
Else
Nowpage=cint (nowpage) ' converts page numbers to digital
End If
--------------------------------
Rs.absolutepage=nowpage ' moves the pointer to the first record of the currently displayed page
-------------------------------
%>
---------------------------------------------
<%
N=1
While not rs.eof and n<=rs.pagesize
Response. Write (RS ("User" & "<br>")
Response. Write (RS ("tt") & "<br>")
N=n+1
Rs.movenext ' shows the page's data
Wend
%>
-------------------------------------------
Total:<%=tatalpages%> page Current:<%=nowpage%> page
<%if nowpage>1 then%>
<a href= "fy.asp?page=<%=nowpage-1%>" > Prev </a>
<%else%>
Previous page
<%end if%>
<%for K=1 to Tatalpages%>
<%if K<>nowpage then%>
<a href= "Fy.asp?page=<%=k%>" ><%=k%></a>
<%else%>
<%=k%>
<%end if%>
<%next%>
<%if Nowpage < Tatalpages then%>
<a href= "fy.asp?page=<%=nowpage+1%>" > next page </a>
<%else%>
Next page
<%end if%> ' plus page number connection
<%if nowpage<>1 then%>
<a href= "fy.asp?page=<%=1%>" > Home </a>
<%else%>
Home
<%end if%>
<%if Nowpage<>tatalpages then%>
<a href= "fy.asp?page=<%=tatalpages%>" > Last </a>
<%else%>
Last
<%end if%>
------------------------------------------------
Such a paging on the OK, hehe, write the bad place please everyone pointing: