Original: thinkphp Page Use example (21)
thinkphp Paging Use
PHP Code:
Public function Fenye () {
$User = M (' Leyangjun ');//Instantiate User object
import (' ORG. Util.page ');//Import page-out class
$count = $User->count ();//query satisfies the required total number of records
$Page = new Page ($count, 2);//Instantiate the total number of incoming records for the paging class and the number of records displayed per page
$show = $Page->show ();//pagination display output
Querying for paging data note the parameters of the limit method to use the properties of the page class
$list = $User->limit ($Page->firstrow. ', '. $Page->listrows)->select ();
$this->assign (' list ', $list);//Assignment Data set
$this->assign (' page ', $show);//Assignment Paging output
$this->display (); Output template
}
HTML page:
<div>
<foreach name= ' list ' item= ' Vo ' >
id:<{$vo. id}>--Name: <{$vo. name}>--Age <{$vo .age}></foreach>
<{$page}>
</div>
thinkphp Page Use example (21)