Thinkphp enables pagination and thinkphp pagination
First, I suddenly found that it was the same as B's.
The code for IndexController. class. php is as follows:
Public function index () {$ m = M ('info'); $ count = $ m-> where ($ where)-> count (); $ pageCount = 10; // number displayed on each page $ Page = new \ Think \ page ($ count, $ pageCount); $ page-> parameter = $ row; // The row here is an array, to pass the query condition $ page-> setConfig ('header', 'loop'); $ page-> setConfig ('first ', 'homepage '); $ page-> setConfig ('prev', 'previous page'); $ page-> setConfig ('Next', 'next page'); $ page-> setConfig ('last ', 'Last page'); $ page-> setConfig ('Theme ', '% FIRST % UP_PAGE % LINK_PAGE % DOWN_PAGE % END % <div id = "pageTips"> nth '. I ('P', 1 ). 'page/Total % TOTAL_PAGE % PAGE ('. $ pageCount. 'items/pages % TOTAL_ROW % information) </div>'); $ show = $ page-> show (); $ list = $ m-> where ($ where)-> order ('Id desc')-> limit ($ page-> firstRow. ','. $ page-> listRows)-> select (); $ this-> assign ('infolist', $ list); $ this-> assign ('show', $ show ); $ this-> display ();}
The index.html code is as follows:
<Table class = "table-hover table-striped" id = "table"> <tr class = "danger"> <th> Category </th> <th> information title </th> <th> item type </th> <th> lost/picked-up time </th> <th> lost/picked-up location </th> <th> release time </th> </tr> <foreach name = "infoList" item = 'vo'> <tr> <td >{$ vo.info _ type} </td> <td> {$ vo.info _ title} </td> <td> {$ vo. thing_type} </td> <td >{$ vo.info _ time} </td> <td >{$ vo.info _ place }</td> <td >{$ vo. create_time }</td> </tr> </foreach> </table> <div class = "page"> <ul >{$ show }</ul> </div>
The css code is as follows:
/* Start paging style */. page {overflow: hidden; margin: 50px 0 50px 100px ;;}. page ul ,. page ul span {float: left; display: inline-block; padding: 0 17px; height: 40px; width: auto; border: 1px solid # dddddddd; border-radius: 4px; background: # fff; text-align: center; line-height: 40px; margin-right: 10px; font-family: "microsoft yahei" simhei sans-serif; color: # 7d7d7d ;}. page ul a: hover {background: #337AB7; color: # fff; text-decoration: none ;}. page ul span. current {background: #337AB7; color: # fff ;}. page ul a: first ,. page ul a: last {float: left; display: inline-block; width: 40px; height: 40px; border-radius: 50%; background: rgb (215,215,217 ); text-align: center; line-height: 40px; margin-right: 10px; font-family: "microsoft yahei" simhei sans-serif;} # pageTips {float: right ;} /* end paging style */
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.