[Original] Sub-page Intermediate Tutorial Step page, how to solve

Source: Internet
Author: User
[Original] Sub-page intermediate tutorial Step into page
In the introductory tutorial, when the page number is mentioned, this article is mainly for discussion here. Welcome to shoot Bricks.

The source code is similar to the previous primary paging tutorial, just a little improvement in the output page link

What is stepping paging? Here's a simple word.

When the total number of pages reached hundreds of, if you follow the previous article in the practice, then the page becomes very ugly, all the page numbers are lost, so it is very unsightly, so it is necessary to control the output page numbers. If you are careful, look at Discuz's pagination. The final page number is always not more than a certain number.


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//step paging, the number of page Flip list always shows only 9 or custom number, this example defines only 9, the current page shows 4 page numbers if ($total _page>9) {if ($page >4)            {$from = $page-4;            $to = $page +4;                if ($to > $total _page) {$from = $total _page-8;            $to = $total _page;            }} else {$from = 1;        $to = 9;        }} else {$from = 1;    $to = $total _page;        } for ($i = $from; $i <= $to; $i + +) {if ($i = = $page) {//Highlight current page number $page _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 "
"Echo" $page _link ";? >



------Solution--------------------
A rare and green article to see.
------Solution--------------------
Good tutorial, for beginners Oh, I have my own pagination class
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.