ThinkPHP paging usage instance analysis _ php instance

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.