This article mainly introduces the paging usage in thinkPHP, and analyzes the thinkPHP Data Query and the related techniques for using the paging class to achieve the paging Effect Based on the instance form, if you need it, refer to the example in this article to describe the paging usage in thinkPHP. We will share this with you for your reference. The details are as follows:
Take an instance for example.
Action page:
Public function show () {import ("ORG. util. page "); // import the paging class $ news = D (" News "); $ count = $ news-> where (''content _ type' = '. $ id)-> count (); // total number of query records $ p = new Page ($ count, 10 ); $ list = $ contact-> where (''content _ type' = '. $ id)-> order ('sort ')-> limit ($ p-> firstRow. ','. $ p-> listRows)-> select (); $ p-> setConfig ('head', 'Data record '); // you can customize the paging style $ p-> setConfig ('prev', "<"); $ p-> setConfig ('Next', '> '); $ p-> setConfig ('first', '<'); $ p-> setConfig ('last', '> '); $ page = $ p-> show (); // The output variable of the navigation bar on the page $ this-> assign ("page", $ page ); // output pagination on the template page $ this-> assign ('info', $ list ); // The queried information is fed back to the template page $ this-> display ('index ');}
Called tpl page: index. php
Custom css styles, mainly used for paging styles
Loop output page information
........................................ ......{$ Page}
The paging style is as follows:
You can customize the style as needed.
I hope this article will help you design php programs based on the thinkPHP framework.