Start Page PHP 3 line code paging algorithm for start and end pages

Source: Internet
Author: User
A good paging algorithm should have the following advantages:
The current page number should be in the middle as far as possible.
If the "Home" and "last" are not available (currently on the first or last page), do not hide the two sets of text so that the link button position changes.
The algorithm is simple.
The following algorithms have the advantages of the preceding 1 and 32.

Copy the Code code as follows:


$curr _index, current page number.
$link _count, number of links.
$page _count, the total number of pages for the current data.
$start, the starting page number when displayed.
$end, the ending page number when displayed.
$start = max (1, $curr _index-intval ($link _count/2));
$end = min ($start + $link _count-1, $page _count);
$start = max (1, $end-$link _count + 1);
Start = Math.max (1, Curr_index-parseint (LINK_COUNT/2));
End = Math.min (Page_count, start + link_count-1);
Start = Math.max (1, End-link_count + 1);

The above describes the start page of the PHP 3 line of code paging algorithm for the start page and the end page, including the Tour start page content, I hope to be interested in PHP tutorial friends helpful.

  • 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.