TP Framework comes with pagination implementation, so use this paging scheme, no need to re-build the wheel
1, look first.
2, source code
/** * TODO basic pagination of the same code encapsulation, make foreground code less * @param $m model, reference Pass * @param $where query criteria * @param int $pagesize query bar per page * @return \think\page*/ Public Static functionGetPage (&$m,$where,$pagesize=10){ $m 1=Clone $m;//Shallow copy a model $count=$m->where ($where),Count();//operations such as join are reset after a habitual operation $m=$m 1;//to maintain a constant, shallow copy of a model $p=NewThink\page ($count,$pagesize); $p->rollpage=5;//Each page displays several pagination tabs $p->listrows = 13;//This sets how many rows are displayed per page $p->lastsuffix=false; $p->setconfig (' header ', ' <li class= ' rows ' > Total <b>%TOTAL_ROW%</b> records per page <b >%LIST_ROW%</b> Section <b>%NOW_PAGE%</b> page/Total <b>%TOTAL_PAGE%</b> page </li> '); $p->setconfig (' prev ', ' prev '); $p->setconfig (' Next ', ' next page ')); $p->setconfig (' Last ', ' End '); $p->setconfig (' first ', ' home '); $p->setconfig (' theme ', '%first%%up_page%%link_page%%down_page%%end%%header% '); $p->parameter=i (' Get. ')); $m->limit ($p->firstrow,$p-listRows); return $p; }
TP Paging
The GetPage method can be placed in the TP framework of the application/common/common/function.php, this document can be specifically placed in a number of common methods, where can be called (such as: Controller files, view files, etc.).
3, calling method
$m = m (' tbl_log_register '); $p= \commonhelper::getpage ($m,$sqlcondition// get paged HTML file $mlist$m->where ($sqlcondition)->order (' start_time desc ')->select (); // Gets the entry for the current page $this->assign (' Fenyeresult ',$mlist); $this->assign (' Pagenum ',$p->show ());
Invoke Scenario
4, is the style (note, to place the page of the HTML page into a div box, the style of the Div box class name is class= "pagination"
)
. Pagination UL{Display:Inline-block;Margin-bottom:0;Margin-left:0;-webkit-border-radius:3px;-moz-border-radius:3px;Border-radius:3px;-webkit-box-shadow:0 1px 2px rgba (0,0,0,0.05);-moz-box-shadow:0 1px 2px rgba (0,0,0,0.05);Box-shadow:0 1px 2px rgba (0,0,0,0.05);}. Pagination ul Li{Display:inline;}. Pagination ul li.rows{Line-height:30px;Padding-left:5px;}. Pagination ul li.rows b{Color:#f00}. Pagination ul Li A,. Pagination ul Li Span{float: Left;padding:4px 12px;Line-height:20px;text-decoration:None;Background-color:#fff;background:url ('.. /images/bottom_bg.png ') 0px 0px;Border:1px solid #d3dbde;/*border-left-width:0;*/Margin-left:2px;Color:#08c;}. Pagination ul Li A:hover{Color:Red;background:#0088cc;}. Pagination ul Li.first-child a,. Pagination ul Li.first-child span{Border-left-width:1px;-webkit-border-bottom-left-radius:3px;Border-bottom-left-radius:3px;-webkit-border-top-left-radius:3px;Border-top-left-radius:3px;-moz-border-radius-bottomleft:3px;-moz-border-radius-topleft:3px;}. Pagination ul. Disabled span,. Pagination ul. Disabled a,. pagination ul. Disabled A:hover{Color:#999;cursor:default;Background-color:Transparent;}. Pagination ul. Active a,. Pagination ul. Active span{Color:#999;cursor:default;}. Pagination ul Li A:hover,. Pagination ul. Active a,. Pagination ul. Active span{Background-color:#f0c040;}. Pagination ul Li.last-child a,. Pagination ul Li.last-child span{-webkit-border-top-right-radius:3px;Border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;Border-bottom-right-radius:3px;-moz-border-radius-topright:3px;-moz-border-radius-bottomright:3px;}. Pagination ul li.current a{Color:#f00;Font-weight:Bold;background:#ddd}
style
5, this article reprinted from http://www.cnblogs.com/suger/p/4024246.html, thanks to his summary, and then in the use of the process found in the tp3.2.3 version of the%list_row% this variable value, and then view the source, This string is not replaced at the end, and the solution is as follows
The path to this file is D:\ThinkPHP\Library\Think\Page.class.php, and then the last replacement can be
TP Framework for paging