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.