Learning purposes: Paging technology, summary The last day of today we learn a little bit more difficult in the ASP page paging technology, after all, when we have n records when we can not put all the records in a page inside it. <% Exec= "SELECT * FROM Test" Set Rs=server.createobject ("Adodb.recordset") Rs.Open exec,conn,1,1 Rs. Pagesize=3 Pagecount=rs. PageCount Page=int (Request. QueryString ("page")) If Page<=0 then page=1 If request. QueryString ("page") = "" Then page=1 Rs. Absolutepage=page %> Rs.pagesize set a page to display the number of records, PageCount is our own definition of a variable, Rs.pagecount is the number of records, page is our own definition of a variable, our next page of the link can be set to list.asp? Page=<%=page+1%>, the next page of the link can be set to List.asp?page=<%=page-1%>, so that when the link is pressed to call the page itself, page this variable is +1 or 1, Finally we let rs.absolutepage (the current page) as page page on it. If request. QueryString ("page") = "" Then page=1, the function of this sentence is that we open the list.asp when we do not follow the page variable, automatically set to page=1, to prevent errors, and when we if....then ... The end if can be omitted when placed on a line. is paging not difficult? Here's a special case: If page=1 and not page=pagecount, there is no previous page at this time, but there is a next page ElseIf Page=pagecount and not page=1, this time there is no next page, but there is a previous page ElseIf page<1, there's no record at this time. ElseIf Page>pagecount Then, there's no record at this time. ElseIf page=1 and Page=pagecount, this time there is no previous page, no next page Else, this time there is a previous page, also has the next page. The following section shows 1 to n pages, and each number after clicking on the number of pages represented in the code, very common OH. <%for I=1 to Pagecount%> <a href= "List.asp?page=<%=i%>" ><%=i%></a><%next%> For....next is the cycle starting at I=1, and the cycle is added 1 to PageCount. Finally, my example contains a simple ASP program, but the function of everything, is the essence of ASP, every ASP large program contains it. add.htm Add Record page add.asp Increase record operation conn.asp Database Links del.asp Delete Record operation Modify.asp Modify Record page Modifysave.asp Modify record operations List.asp This is the core of this program, through this page to achieve the record add, modify, delete. Test.mdb Database , which has aa,bb two fields: AA numeric type can only accept numbers, BB is character type. OK, 10 days to the end of today, I think this tutorial is to let everyone get started, we feel that writing is not to blame will not be able to beginners and masters are taking care of it, and finally I would like to say that today's example is the essence of ASP, we must study hard, through the program, you will find that you will be ASP. Thank you for your support! |