CodeIgniter Page class Pagination Use Method example, codeigniter example
The example of this article describes how to use the CodeIgniter page class pagination. Share to everyone for your reference, as follows:
Controller controllers (application/controller/page.php files):
Public Function Index () {$this->load->model (' Home_model ', ' ", TRUE); $config = Array (); $config [' per_page '] = $this->per_page; The number of data displayed per page $current _page = intval ($this->input->get_post (' Per_page ', true)); Gets the number of page pages currently paged//page restore if (0 = = $current _page) {$current _page = 1; } $offset = ($current _page-1) * $config [' per_page ']; Set offset qualification data query start position (starting with $offset bar) $result = $this->home_model->index ($offset, $config [' Per_page '], $order = ' id des C '); $config [' base_url '] = $this->config->item (' Base_url '). ' Admin/home/index? '; $config [' first_link '] = $this->first_link;//home $config [' prev_link '] = $this->prev_link;//prev $config [' Next_link '] = $this->next_link;//next $config [' last_link '] = $this->last_link;//last $config [' Total_rows ' ] = $result [' Total '];//number $config [' num_links '] = 3;//number of connections $config [' use_page_numbers '] = TRUE; $config [' page_query_string '] = TRUE; $thisLoad->library (' pagination ');//Load CI pagination class $this->pagination->initialize ($config); $result = Array (' list ' = = $result [' list '], ' total ' and ' = ' $result [' total '], ' current_page ' = $current _page, ' per_page ' = $config [' per_page '], ' page ' and $this->pagination->create_links (), ); $this->load->view (' Admin/home ', $result);}
Model models (application/model/home_model.php file):
Public Function Index ($offset, $num, $order = ' id desc ') { $query = $this->db->query ("Select Name_cn,mall_type, Create_time from smzdm_mall WHERE is_deleted = 0 ORDER by {$order} limit {$offset},{$num} "); Return Array ( ' total ' = $this->db->count_all (' Smzdm_mall ', Array (' is_deleted ' = ' 0 ') '), ' list ' = > $query->result (), );}
More interested in CodeIgniter related content readers can view this site topic: "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "PHP date and Time usage summary", "PHP object-oriented Programming introduction Tutorial", " PHP String Usage Summary, "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"
It is hoped that this article is helpful to the PHP program design based on CodeIgniter framework.
Articles you may be interested in:
- CodeIgniter How to send HTML messages using the SMTP service
- CodeIgniter how to send messages and print debug information
- CodeIgniter How to send a message
- CodeIgniter implement sending messages with attachments
- Analysis of Third_party usage of CodeIgniter Auxiliary third-party class library
- CodeIgniter Extending Core class examples
- Setting enhanced configuration class instance for CI (CodeIgniter)
- PHP implementation of CodeIgniter Shopping cart class
- CodeIgniter instance of Dom class usage
- CodeIgniter Shopping Cart class cannot add Chinese solution
- CodeIgniter e-Mail based email method
http://www.bkjia.com/PHPjc/1117097.html www.bkjia.com true http://www.bkjia.com/PHPjc/1117097.html techarticle CodeIgniter Page class pagination Use Method Example, codeigniter example This article describes the CodeIgniter pagination class pagination usage. Share to everyone for your reference, as follows: ...