How to set the pagination in CodeIgniter?

In this i would like to explain about how to set the pagination in codeigniter framework. See the code below: to set the pagination in CodeIgniter

How to set the pagination in CodeIgniter by Anil Kumar Panigrahi

How to set the pagination in CodeIgniter by Anil Kumar Panigrahi

In the controller: add the below code

 $this->load->library('pagination');
 $config['total_rows'] = $this->db->count_all('code_image');
 $config['per_page'] = '3';
 $config['full_tag_open'] = '<p>';
 $config['full_tag_close'] = '</p>';
 $config['base_url'] = base_url().'upload/list_images/';
 $this->pagination->initialize($config);
 //echo base_url();
 $this->load->model('code_image');
 $data['images'] = $this->code_image->get_images($config['per_page'],$this->uri->segment(3));

 

In the View: add the below code

<?php echo $this->pagination->create_links(); ?>

Note : It will only display the 3 images per page.
 
 

Anil Kumar Panigrahi

With more than 10 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : [email protected]

You may also like...

1 Response

  1. Hetal says:

    This will definitely be helpful. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *