thinkphp framework, after the data is cached dynamically, or the data has been read out, what to do about paging

Source: Internet
Author: User

//after reading the cache, assign a value to the array, which is handled by the Array_slice function, such as:$blog= S (' Blogname ');//Assign Value$count=Count($blog);//statistics of number of bars$page=NewPage ($count, 12);//instantiate the Page class$thisBlog =Array_slice($blog,$page->firstrow,$page->listrows);//Assign to Template$thispage =$page-Show ();$thisDisplay ();

After the revision

/** * Relevant expected position recommended CV data pagination * * Combined with the Get_jianli_hy_tuijian () method under the same controller * * $list obtained data * * $num a page showing a few * * $p need Data on page Number * * * method Array_slice (); Can Baidu Php Array_slice method you will understand * **/     Public functionGet_tj_jianli_page ($list,$num,$p){        $_get[' P '] =$p; $count=Count($list);//the total number of records that the query meets the requirements        $Page=New\think\page ($count,$num);//instantiate the total number of incoming records in a paging class and the number of records displayed per page        $show=$Page->show ();//pagination Display Output        $data[' list '] =Array_slice($list,$Page->firstrow,$Page->listrows);//Assign to Template        $data[' P '] =$count/$num>$p?$p+1: ";//Just to make the next page        return $data; }

thinkphp framework, after the data is cached dynamically, or the data has been read out, what to do about 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.