This example describes the paging usage in thinkphp. Share to everyone for your reference, specific as follows:
Take an example.
Action page:
Public function Show () {
import ("ORG.") Util.page "); Import a paging class
$news =d ("News");
$count = $news->where (' content_type ' = '. $id)->count (); The total number of bars in the query record
$p = new Page ($count,);
$list = $contact->where (' content_type ' = '. $id)->order (' sort ')->limit ($p->firstrow. ',' . $p->listrows)->select ();
$p->setconfig (' header ', ' data '); Pagination styles can be customized
$p->setconfig (' prev ', ' < ');
$p->setconfig (' Next ', ' > ');
$p->setconfig (' A ', ' << ');
$p->setconfig (' Last ', ' >> ');
$page = $p->show (); The output variable of the paging navigation bar
$this->assign ("page", $page);////////////////////
->assign (' info ', $list) in the template page $this Query feedback to the template page
$this->display (' index ');
}
Called TPL page: index.php
Custom CSS styles, primarily for pagination styles
<style type= "Text/css" >
page{
font-size:18px;
Page. current{
width:10px;
font-size:16px;
margin-left:5px;
padding:2px;
border:1px solid #000;
Page a{
min-width:10px;
font-size:16px;
margin-left:5px;
border:1px solid #000;
padding:2px;
}
</style>
Circular output Paging information
................
...............
...............
<div class= "page" > {$page} </page> <!--output paging information-->
The paging styles are as follows:
Customize the styles you want as needed
I hope this article will help you with the PHP program design based on thinkphp framework.