Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Pagination

sjlu edited this page May 29, 2012 · 1 revision

CodeIgniter includes a really snazzy pagination class you can use. Auto generates the HTML code based on what you input into it.

Example

$this->load->library('pagination');
$config['total_rows'] = $this->admin_model->result_count();
$config['per_page'] = 2;
$config['num_links'] = 1;
 
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
  • per_page lists how many elements should show on one page
  • num_links displays how many links should be displayed on 1 side, dis-including the middle. Meaning, setting this value to 1 means that there will be 3 pagination elements displayed.
  • Write this in the controller.
  • Pagination class generates HTML, you need to make sure you pass it to your view.

Screenshot

Pagination