PHP Universal Paging Type

Source: Internet
Author: User
PHP Universal Paging Class
 
  

?

 
  Getallpage ()} page, {$page->getcurrentpage ()} page "; $links = $this->getlinkstring ($param); if ($page->hasprevious ()) $temp. = "Getcurrentpage ()-1)." ' > Previous page "; else{$temp. =" Prev ";} for ($i = $page->getcurrentpage (); $i <= $page->getallpage () && $i <= $page->getperrecords (); $i + + {$temp. = "{$i}";} if ($page->hasnext ()) $temp. = "Getcurrentpage () +1)." ' > next page "; else{$temp. =" Next page ";} return $temp;} Public Function getlinkstring ($param) {$str = "", $attr =$_get;unset ($attr [$param]), if ($attr) {foreach ($attr as $key = > $val) {if ($str = = "") {$str. = "? $key = $val";} else{$str. = "& $key = $val";}} $str. = "& $param";} else{$str. = "$param";} return $str;}}? >

??

 Allpage;} /** * @return The $allRecords */public function getallrecords () {return $this->allrecords;} /** * @return The $perRecords */public function getperrecords () {return $this->perrecords;} /** * @return The $currentPage */public function getcurrentpage () {return $this->currentpage;} /** * @param $allPage the $allPage to set */public function Setallpage ($allPage) {$this->allpage = ($allPage% $this Perrecords = = 0)? ($allPage/$this->perrecords):($allPage/$this->perrecords+1); $this->allpage=intval ($this->allpage);} /** * @param $allRecords the $allRecords to set */public function Setallrecords ($allRecords) {$this->allrecords = $allR Ecords;} /** * @param $perRecords the $perRecords to set */public function Setperrecords ($perRecords) {$this->perrecords = $perR Ecords;} /** * @param $currentPage the $currentPage to set */public function Setcurrentpage ($currentPage) {if ($currentPage < 1) $this->currentpage = 1;else if ($currentPage > $this->allpage) $thIs->currentpage = $this->allpage;else$this->currentpage= $currentPage;} Public Function Hasnext () {return $this->currentpage< $this->allpage;} Public Function hasprevious () {return $this->currentpage>1;} Public Function Getendindex () {return (($this->currentpage-1) * $this->perrecords) + $this->perrecords) >$ This->allrecords? ((($this->currentpage-1) * $this->perrecords) + $this->perrecords)-$this->allrecords: $this Perrecords;} Public Function Getstartindex () {return ($this->currentpage-1) * $this->perrecords;}}? >

?

 list= $list; $this->page=new page ();} /** * * @param unknown_type $rows The amount of data displayed * @param unknown_type $current Current page */public function init ($rows =5, $current) {$thi S->page->setallrecords (Count ($this->list)), $this->page->setperrecords ($rows); $this->page- >setallpage (Count ($this->list)), $this->page->setcurrentpage ($current), $this->list=array_slice ($ This->list, $this->page->getstartindex (), $this->page->getendindex ());} /** * Get paging variable */public function GetVar () {return $this->list;} /** * @return The $param */public function GetParam () {return $this->param;} /** * @param $param the $param to set */public function SetParam ($param) {$this->param = $param;} /** * Load plugin information, get generated link, adorner mode * @param unknown_type $link */public function GetLink ($link =null) {if (!empty ($link) | |! (($link instanceof ILink))) $link =new LinkAdapter (); return $link->parse ($this->page, $this->param);}}? >

?

 
  SetParam ("page"), $page->init (30,$_request[' page '), $list = $page->getvar (); foreach ($list as $val): Echo $val. '
'; Endforeach;echo $page->getlink ();? >

? download

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