PHP Paging code.

Source: Internet
Author: User

$result _count=select ("Hy_news_en", $where, ' ', ' ', ' count (1) ');    $count =mysql_fetch_array ($result _count); $count = $count [0];//total number of bars $page _size=5;//per page $page _count=ceil ($count/$page _size);//Total pages
$p =$_request[' P ']> $page _count? $page _count:$_request[' P '];//start page, if more than the total number of pages, the total number of pages $p = $p <1?1: $p;//If less than 0, the first page
$start _p=intval (($p-1)/$page _size);
On Page_size page if ($p > $page _size) {$page _prev= $start _p* $page _size-($page _size-1); $page _prev= ' latest_pro.php?act= '. $_request[' act ']. '    &p= '. $page _prev; }//Under Page_size page if (($start _p* $page _size+ $page _size) < $page _count) {$page _next= $start _p* $page _size+ ($page _size+1    ); $page _next= ' latest_pro.php?act= '. $_request[' act ']. '    &p= '. $page _next; }
Intermediate page_size page $end _count= ($start _p* $page _size+ $page _size) > $page _count? $page _count: ($start _p* $page _size+$ Page_size);
for ($i = $start _p* $page _size+1; $i <= $end _count; $i + +) {$page [$i]= ' latest_pro.php?act= '. $_request[' act ']. '      &p= '. $i; }
$p = $page _size* ($p-1);//Database starting from 0 $limits = "{$p},{$page _size}"; Pagination processing End

From for notes (Wiz)

PHP Paging code.

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.