PHP implementation of simple and practical pagination class code, simple and practical paging
This paper describes the simple and practical PHP implementation of the paging class. Share to everyone for your reference, as follows:
<?php class Page {private $total; Total Records private $pagesize; How many private $limit are displayed per page; Limit private $page; Current page number private $pagenum; Total page number private $url; Address private $bothnum; On both sides keep the number of paging amount//Construction method Initialize Public function __construct ($_total, $_pagesize) {$this->total = $_total? $_total:1; $this->pagesize = $_pagesize; $this->pagenum = ceil ($this->total/$this->pagesize); $this->page = $this->setpage (); $this->limit = "Limit". ($this->page-1) * $this->pagesize. ", $this->pagesize"; $this->url = $this->seturl (); $this->bothnum = 2; }//Interceptor Private Function __get ($_key) {return $this->$_key; }//Gets the current page number private function Setpage () {if (!empty ($_get[' page '))) {if ($_get[' page '] > 0) {i F ($_get[' page '] > $this->pagenum) {return $this->pagenum; } else {return $_get[' page ']; } } else {return 1; }} else {return 1; }}//Get address Private Function SetUrl () {$_url = $_server["Request_uri"]; $_par = Parse_url ($_url); if (isset ($_par[' query ')) {parse_str ($_par[' query '],$_query); unset ($_query[' page '); $_url = $_par[' path ']. '? '. Http_build_query ($_query); } return $_url; }//Digital directory Private Function PageList () {for ($i = $this->bothnum; $i >=1; $i-) {$_page = $this->page-$i; if ($_page < 1) continue; $_pagelist. = ' URL. ' &page= '. $_page. ' " > '. $_page. ' '; } $_pagelist. = ''. $this->page. ''; for ($i =1; $i <= $this->bothnum; $i + +) {$_page = $this->page+ $i; if ($_page > $this->pagenum) break; $_pagelist. = ' URL. ' &page= '. $_page. ' " > '. $_page. ' '; } return $_pagelist; }//Home Private Function First () {if ($this->page > $this->bothnum+1) {return ' URL. >1 ... '; }}//prev Private Function prev () {if ($this->page = = 1) {return 'Previous Page'; } return ' URL. ' &page= '. ($this->page-1). ' " > previous page '; }//Next Private Function next () {if ($this->page = = $this->pagenum) {return 'Next Page'; } return ' URL. ' &page= '. ($this->page+1). ' " > next page '; }//End Private Function last () {if ($this->pagenum-$this->page > $this->bothnum) {return ' ... URL. ' &page= '. $this->pagenum. ' " > '. $this->pagenum. ' '; }}//Paging information public Function showpage () {$_page. = $this->first (); $_page. = $this->pagelist (); $_page. = $this->last (); $_page. = $this->prev (); $_page. = $this->next (); return $_page; }}?>
The paging style looks like this:
Instructions for use:
<?php $_page = new page ($_total,$_pagesize); Where $_total is the total number of data sets, $_pagesize is the number displayed per page. >
More about PHP related content readers can view the topic: "PHP File Operation Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP Basic Grammar Introductory Tutorial", "PHP operation Office Document tips summary (including word, excel,access,ppt), "PHP Date and Time usage summary", "PHP primer for Object-oriented programming", "PHP String Usage Summary", "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"
I hope this article is helpful to you in PHP programming.
Articles you may be interested in:
- PHP implements a customizable style of paging class
- PHP custom pagination Class Complete instance
- Two All-purpose PHP paging class
- PHP Simple Pagination Class implementation method
- PHP Pagination Class Collection
- An instance of Thinkphp page class modified by Dedecms drop-down page style
- Efficient MongoDB PHP Paging class (Do not use skip)
- thinkphp use of experience sharing-page class page usage
- Thinkphp the use of pagination class
- Beautiful PHP Pagination Class code
- Imitation Aspnetpager of a PHP page class code attached to the source download
- PHP Ajax Pagination Class code
http://www.bkjia.com/PHPjc/1119981.html www.bkjia.com true http://www.bkjia.com/PHPjc/1119981.html techarticle PHP Implementation of simple and practical pagination class code, simple and practical pagination This article describes the PHP implementation of a simple and practical paging class. Share to everyone for your reference, specifically as follows: PHP class Pag ...