Thursday, September 3, 2009

To set the pagination in CodeIgniter

See the code below: to set the pagination in CodeIgniter

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'] = ‘

’;
$config['full_tag_close'] = ‘

’;
$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


pagination->create_links(); ?>


It will only display the 3 images per page.

1 comment:

  1. hi could you give same image gallery with path from database

    with paging.

    ReplyDelete