[Original] Sub-page beginner tutorial, Suitable for beginners
The corresponding girl moderator's call, first caught dead, right when a start. Novice can see, master do not look.
PHP Code
<title>Pagination instance</title>
$total _page $total _page: $page;//Avoid $_get["page"] greater than total pages//page link start $page_link= "", if ($total _page>1) {$page _link= "altogether { $total _page} page "; $page _link.= "The current {$page} page"; $page _link.= "Home"; if ($page >1) {//page number is greater than 1, display the previous page link $pre _page= $page-1; $page _link.= "<<"; }//Flip list for ($i =1; $i <= $total _page; $i + +) {if ($i = = $page) {//Highlight current page number $pag E_link.= "$i"; } else {$page _link.= "$i"; }}//page is less than the total number of pages to display the next page link $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 "
After reading, consider the following questions:
1. If there are a lot of page numbers, there may be hundreds, this page link list how to output?
Not to be continued ....
------Solution--------------------
Thank you for sharing the small white I paged is home previous next last total x page wood has the middle of the page number list study Thank you Jordan Brother to share!
------Solution--------------------
Study, sincerely thank you, I am a novice ...
------Solution--------------------
I have written a generic paging code for Java. Looks like this.
<< < [1] [2] [3] 4 [5] [6] [7] [8] [9] [ten] > >>
Click >> Post
<< < [[] [] [] [] [] [] [] [] [] [] [] > >>
Then click >> After
<< < 21 [22] [23]