thinkphp Implementing Data Paging

Source: Internet
Author: User

Method One:

1  Public functionshow_cate () {2         3         $category _name=Array(4' 1 ' and ' the forefront of political and legal governance ',5' 2 ' = ' policies and regulations ',6' 3 ' = ' Peace building ',7' 4 ' = ' notification announcement ',8' 5 ' = ' theory discussion ',9' 6 ' = ' local dynamics ',Ten' 7 ' = ' Team building ', One             ); A         $category _id= I (' get.category_id '); -         $model= M (' zx_article '); -                                  //calculate the total number of data bars to display the         $count=$model->where (' category_id = '.$category _id)->order (' article_id desc ')Count(); -                                 //instantiate the page class, passing in the total number of bars and the number of bars to display per page -         $page=New\think\page ($count, 2); -                               //use the Limit function to specify the number of queries and actions +         $data=$model->where (' category_id = '.$category _id)->order (' article_id desc ')->limit ($page->firstrow. ', '.$page->listrows)Select (); -                                 //Pass data to template +         $this->assign (' Data ',$data); A                                //Call the show () function of the page class
at $this->assign (' page ',$page-Show ()); - $this->assign (' name ',$category _name[$category _id]); - $this-display (); -}

thinkphp Implementing Data Paging

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.