PHP implementation of a simple digital paging function detailed

Source: Internet
Author: User
This article mainly introduces PHP simple implementation of the digital paging function, combined with examples of PHP digital paging related mathematical operations and string manipulation related skills, the need for friends can refer to the following

Specific as follows:

<?phpheader (' content-type:text/html; Charset=utf-8 ');//Pagination $page=$_get[' page ']; $allcount = +; $page _size =10;$ Page_show =5; $page _count = Ceil ($allcount/$page _size); if ($page <= 1 | | $page = = ") $page = 1;if ($page >= $page _coun T) $page = $page _count; $pre _page = ($page = = 1)? 1: $page-1; $next _page= ($page = = $page _count)? $page _count: $page + 1; $pagenav. = "$page/$page _count page Total $allcount records"; $pagenav. = "<a href= '? page=1 ' > Home </ A> "; $pagenav. =" <a href= '? page= $pre _page ' > Previous </a> ";//start of current display $page_show_start = (ceil ($page/$page _ Show)-1) * $page _show;//Show Paging $page_show_str = "; if ($page _show> $page _count) {$page _show = $page _count;}  for ($j =1; $j <= $page _show; $j + +) {$page _show_now = $page _show_start+ $j; if ($page = = $page _show_now) {$page _show_str. = "<a href= '? page= $page _show_now ' ><strong> $page _show_now  </strong></a> ";  }else{$page _show_str. = "<a href= '? page= $page _show_now ' > $page _show_now</a>"; }} $pagenav. = $page _show_str; $pagenav. = "<a href= '? page= $next _page ' > Next </a>"; $pagenav. = "<a href="? Page= $page _ Count ' > End </a> "; Echo ' <p class=" page "> '. $pagenav. ' </p> ';? >

The effect is as follows:

Summary: The above is the entire content of this article, I hope to be able to help you learn.

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.