The ThinkPHP3.2.3 paging method is described in detail, and thinkphp3.2.3 paging. ThinkPHP3.2.3 describes how to implement paging. thinkphp3.2.3 this article describes how to implement paging using ThinkPHP3.2.3. For your reference, please refer to ThinkPHP3.2.3 as follows:
This example describes how ThinkPHP3.2.3 implements paging. We will share this with you for your reference. The details are as follows:
The first thing to understand is that ThinkPHP3.2.3's paging class has been moved to Think \ Page. class. php, which is somewhat different from the previous version. it is similar to the previous version, but the default effect is not flattering, so it is best to add some styles on your own.
I added some styles (not very nice). you can improve the paging style on your own ,:
Here I made the page settings into a function getpage, and put this method into Application \ Common \ function. php (note that the function is not a class) to facilitate calling elsewhere. the code is as follows:
<? Php/*** encapsulate the same code of the TODO basic page, less front-end code * @ param $ count total number of records to be paged * @ param int $ pagesize number of queries per Page * @ return \ Think \ Page */function getpage ($ count, $ pagesize = 10) {$ p = new Think \ Page ($ count, $ pagesize); $ p-> setConfig ('header ','
Total% TOTAL_ROW %Record No.% NOW_PAGE %Page/total% TOTAL_PAGE %Page'); $ P-> setConfig ('prev', 'Previous page'); $ p-> setConfig ('next', 'next page '); $ p-> setConfig ('last', 'Last page'); $ p-> setConfig ('first ', 'homepage'); $ p-> setConfig ('theme ', '% FIRST % UP_PAGE % LINK_PAGE % DOWN_PAGE % END % HEADER %'); $ p-> lastSuffix = false; // The last page is not displayed as the total number of pages. return $ p;}?>
The code used in the controller is as follows:
Public function showAllUsers () {$ m = M ('user'); $ where = "id> 10"; $ count = $ m-> where ($ where) -> count (); $ p = getpage ($ count, 1); $ list = $ m-> field (true)-> where ($ where) -> order ('id')-> limit ($ p-> firstRow, $ p-> listRows)-> select (); $ this-> assign ('select ', $ list); // assign a dataset $ this-> assign ('page', $ p-> show ()); // value-assigned paging output $ this-> display ();}
Next use in View:
User information output
Current login user: {$ Think. session. admin} |
User information |
ID |
User name |
Password |
{$ User. id} |
{$ User. account} |
{$ User. pwd} |
{$ Page} |
The sample mypage.css for setting the page Sharding is as follows:
.pages a,.pages span { display:inline-block; padding:2px 5px; margin:0 1px; border:1px solid #f0f0f0; -webkit-border-radius:3px; -moz-border-radius:3px; border-radius:3px;}.pages a,.pages li { display:inline-block; list-style: none; text-decoration:none; color:#58A0D3;}.pages a.first,.pages a.prev,.pages a.next,.pages a.end{ margin:0;}.pages a:hover{ border-color:#50A8E6;}.pages span.current{ background:#50A8E6; color:#FFF; font-weight:700; border-color:#50A8E6;}
In this way, you can.