CodeIgniter creating pagination

I’ll use CodeIgniter’s pagination library to show you how you can create a paginated list of results from a MySQL database. Along the way, you’ll also see how to fix a problem with the pagination links that the library might produce.That is pretty easy to use and implement.In this tutorial I’ll do a quick example of returning a set of results from a database and paginating those results.

in your controller

function index()
{
          $this->load->library('pagination'); // call to the library
          $config['base_url'] = base_url().'index.php/users/index/'; // get the url
          $config['total_rows'] = $this->db->count_all('users');
          $config['per_page'] = 5; // number of records to display
          $this->pagination->initialize($config);
          $data['pagination_links'] = $this->pagination->create_links(); // creating pagination links
          $this->db->order_by('user_id', 'DESC');
          $data['users_query'] = $this->db->get('users', $config['per_page'], $this->uri->segment(3));
          $this->load->view('users_index', $data);
}

Note
$config[‘base_url’] – Full URL to the controller function containing your pagination.
$config[‘total_rows’] – Represents the total rows in the result set you are creating pagination for.
$config[‘per_page’] – Number of items/records to show per page.
In the View file,

          result() as $row) : ?>
          

User Name: user_name; ?>

Email: email; ?>

Profile: profile_details; ?>


That’s only.