Example Analysis _php example of thinkphp in the case of paging

Source: Internet
Author: User

This example describes the paging usage in thinkphp. Share to everyone for your reference, specific as follows:

Take an example.

Action page:

Public function Show () {
   import ("ORG.") Util.page "); Import a paging class
   $news =d ("News");
   $count = $news->where (' content_type ' = '. $id)->count (); The total number of bars in the query record
   $p = new Page ($count,);
   $list = $contact->where (' content_type ' = '. $id)->order (' sort ')->limit ($p->firstrow. ',' . $p->listrows)->select (); 
   $p->setconfig (' header ', ' data '); Pagination styles can be customized
   $p->setconfig (' prev ', ' < '); 
   $p->setconfig (' Next ', ' > '); 
   $p->setconfig (' A ', ' << '); 
   $p->setconfig (' Last ', ' >> '); 
   $page = $p->show (); The output variable of the paging navigation bar
   $this->assign ("page", $page);////////////////////
   ->assign (' info ', $list) in the template page $this Query feedback to the template page
   $this->display (' index ');
}

Called TPL page: index.php

Custom CSS styles, primarily for pagination styles

<style type= "Text/css" >
page{
 font-size:18px;
Page. current{
 width:10px;
 font-size:16px;
 margin-left:5px;
 padding:2px;
 border:1px solid #000;
Page a{
 min-width:10px;
 font-size:16px;
 margin-left:5px;
 border:1px solid #000;
 padding:2px;
}
</style>

Circular output Paging information

................
...............
...............
<div class= "page" > {$page} </page> <!--output paging information-->

The paging styles are as follows:

Customize the styles you want as needed

I hope this article will help you with the PHP program design based on 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.