The php paging tutorial is as follows: & amp; lt ;? Phpecho & quot; original php Tutorial & quot; // Connect to database $ con = mysql_connect (& quot; localhost & quot;, & quot; root & quot ;, & quot ;);
The php paging tutorial is as follows:
= $ TotalPageCount )? $ TotalPageCount: $ nowPage + 1; // offset $ offset = ($ nowPage-1) * $ pageSize;/* OK, which gets the data, in fact, as long as you understand the SQL statement, you will understand the paging principle * select * from table limit $ offset, $ size paging execution statement */$ SQL = "select * from stu_msg limit $ offset, $ pageSize "; $ result = mysql_query ($ SQL, $ con); while ($ arr = mysql_fetch_array ($ result) {echo $ arr ['mid ']. $ arr ['content']."
";}Echo" homepage "; echo" previous page "; echo" next page "; echo" last page ";?>
The above php instance runs as follows:
The above php code has been commented out clearly. I believe you will understand it! The following is a simple analysis of the php Tutorial:
1. the global variable $ _ SERVER ['php _ SELF '] is the absolute path for getting the script variable. you can print it out and check it out.
2. the essence of paging is to display data in a database segment, for example, in the above php instance:
Extract the first five (first page): select * from table limit
Retrieve 5th to 10th entries (second page): select * from table limit 5, 5
This gives the formula for offset: $ offset = ($ nowPage-1) * $ pageSize;
3. the intval () function is used to obtain the integer value of the variable.
~ Is php paging so easy !~