[Original] the paging Elementary tutorial is suitable for beginners who call for the neighborhood moderator. You can watch it for new users. PHPcode & lt ;! DOCTYPEhtmlPUBLIC & quot;-// W3C // DTDXHTML1.0Transitional // EN & quot; http: // [original] paging Elementary tutorial, suitable for beginners
The call of the corresponding Niu moderator is ugly, and the right should be a reference. You can watch it for new users.
PHP code
Paging instance
$ Total_page? $ Total_page: $ page; // avoid $ _ GET ["page"] exceeding the total number of pages // The page turning link starts $ page_link = ""; if ($ total_page> 1) {$ page_link = "total {$ total_page} pages"; $ page_link. = "current page {$ page}"; $ page_link. = "homepage"; if ($ page> 1) {// when the page number is greater than 1, the page turning link of the previous page is displayed $ pre_page = $ page-1; $ page_link. = "<" ;}// page flip list for ($ I = 1; $ I <= $ total_page; $ I ++) {if ($ I = $ page) {// highlight the current page number $ page_link. = "$ I";} else {$ page_link. = "$ I" ;}}// when the page number is smaller than the total page number, the next page flip link is displayed. $ next_page = $ page + 1; if ($ next_page <$ total_page) {$ page_link. = ">" ;}$ page_link. = "Last page";} // output record $ offset = ($ page-1) * $ page_size; $ query = mysql_query ("select * from product limit $ offset, $ page_size ") or die (mysql_error (); echo"
"; While ($ rs = mysql_fetch_array ($ query) {echo"
- {$ Rs ["id"]}-{$ rs ["ename"]}
";} Echo"
"; Echo" $ page_link ";?>
Think about the following questions:
1. if there are many page numbers, there may be hundreds. how can I output this link list?
Not yet to be continued ....
------ Solution --------------------
Thank you for sharing. my pages are all on the homepage. the last page of the previous page has a total of X pages. there is a list of intermediate pages. thank you, Jordan!
------ Solution --------------------
Thank you! I'm a newbie ......
------ Solution --------------------
I wrote a general paging code for JAVA. Similar to the following:
<[1] [2] [3] 4 [5] [6] [7] [8] [9] [10]>
Click>
<11 [12] [13] [14] [15] [16] [17] [18] [19] [20]>
Click> Later
<21 [22] [23]