How to use the paging of the CI framework (including code for Beginners)

Source: Internet
Author: User
Here are some of my business code to share with you: Here are two methods in controller:

Here is some of my business code to share with you:

Here are two methods in controller:

// Pagination settings
Function page_config ($ count, $ add ){
$ Config ['base _ url'] = $ add; // you can specify the base address.
$ Config ['uri _ segment '] = 3; // you can specify the offset of the segment in the url used to pass the page splitter.
$ Config ['total _ rows '] = $ count;
$ Config ['per _ page'] = 10; // The number of data displayed on each page
// $ Config ['first _ link'] = 'homepage ';
// $ Config ['last _ link'] = 'Last page ';
$ Config ['next _ link'] = 'next page> ';
$ Config ['prev _ link'] =' <上一页';
Return $ config;
} // Business ticket list
Function market_list (){
$ Data ['action _ market '] = $ this-> user_action ()-> action_market;
$ This-> session ();
$ Add = 'market/market_list ';
$ Count = $ this-> db-> count_all ('market _ sig '); // Obtain the quantity
$ Config = $ this-> page_config ($ count, $ add );
$ This-> pagination-> initialize ($ config); // sets the complete page splitter.
$ This-> load-> library ('table'); // load a table class
$ Data ['list'] = $ this-> Mmarket-> market_sig ($ config ['per _ page'], $ this-> uri-> segment (3 )); // Here we can see the model class of the market.
$ This-> load-> view ('market/market_list ', $ data );
}

The methods in the model class are as follows:

// List
Function market_sig ($ n, $ o ){
If ($ o = '') {$ o = 0 ;}
$ Result = $ this-> db-> query ("select * from market_sig where del! = 0 order by sig_time desc limit $ o, $ n ");
$ Re = $ result-> result ();

Return $ re;
}

In the view, you only need to write it like this:

Pagination-> create_links ();?>

The code is for your reference. if you have any questions, please contact me.

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.