title: How to paginate with codeigniter 3.0.1
body: <p>I am trying to create pagination using CodeIgniter. It displays links fine, but when I click the links it shows 404 error. How to solve this?</p>
  
  <p><strong>Controller Example.php</strong></p>
  
  <pre><code>class example extends CI_controller
  {
  
   public function __construct()
    {
      parent::__construct();
      $this-&gt;load-&gt;model('Donor_model');
      $this-&gt;load-&gt;library('pagination');
      $this-&gt;load-&gt;helper('url');
      $this-&gt;load-&gt;library('form_validation');
  
    }
  
  
    public function get_details()
     {
      $config['base_url'] = base_url('info');
      $config['total_rows'] = $this-&gt;Donor_model-&gt;count();
      $config['per_page'] = 10;
      $config['uri_segment'] = 3;
      $choice = $config['total_rows']/$config['per_page'];
      $config['num_links'] = round($choice);
  
  
      $this-&gt;pagination-&gt;initialize($config);
  
      $page =($this-&gt;uri-&gt;segment(3)) ? $this-&gt;uri-&gt;segment(3) : 0;
      $data['data'] = $this-&gt;Donor_model-&gt;get_data([], [],$config['per_page'],$page);
      $data['links'] = $this-&gt;pagination-&gt;create_links();
  
  
      $this-&gt;load-&gt;view('admin/info',$data);
     }
  }
  </code></pre>
  
  <p></p>
  
  <p><strong>Model (Example_Model.php)</strong></p>
  
  <p><code>Example_Model</code> class which extends <code>My_Model class</code>: </p>
  
  <pre><code>class Donor_model extends MY_Model
  {
  protected $table = 'donors';
  
  public function __construct()
  {
      //call the MY_Model construtor
      parent::__construct();  
  }   
  
  public function get_data($where, $fields,$limit, $start)
  {
      return $this-&gt;get($where,$fields , $limit, $start);
  }
  public function count_data()
  {
  
      return $this-&gt;count();
  }
  </code></pre>
  
  <p></p>
  
  <p><strong>Model (My_Model.php)</strong></p>
  
  <pre><code>class MY_Model extends CI_Model
  {
  protected $table = NULL;
  
  // protected $table_fields = [];
  
  // protected $fillable = [];
  
  // protected $protected = [];
  
  protected $primary_key = 'id';
  
  
  
  function __construct()
  {
      parent::__construct();
      $this-&gt;load-&gt;database();
  }
  
  /**
  * Return all table contents
  * @param array $where ,$fields, $limit 
  * @return array
  *defualt $sortOrder = dsc
  */
  
  // public function get(array $where = NULL, $limit = 1000, $sortOrder = 'dsc')
  public function get(array $where = NULL, array $fields = NULL, $limit = NULL, $start = NULL)
  {
      $query = NULL;
      // return all records with all fields from table
      if($fields == NULL and $where == NULL){
  
          $this-&gt;db-&gt;limit($limit, $start);
          $query = $this-&gt;db-&gt;get($this-&gt;table);
          if ($query-&gt;num_rows() &gt; 0 ) {
  
              return $query-&gt;result();
          }
          else
              return false;
      }
  
      // rteurn all records with only my fields
      elseif($fields != NULL and $where == NULL){
  
          $this-&gt;db-&gt;limit($limit, $start);
          $this-&gt;db-&gt;select($fields);
          $query = $this-&gt;db-&gt;get($this-&gt;table);
          if ($query-&gt;num_rows() &gt; 0) 
              return $query-&gt;result();
  
          else
              return false;
  
      }
  
      // return all records through condition
      elseif($fields == NULL and $where != NULL){
  
          $this-&gt;db-&gt;limit($limit, $start);
          $query = $this-&gt;db-&gt;get_where($this-&gt;table, $where);
          if ($query-&gt;num_rows() &gt; 0) 
              return $query-&gt;result();
  
          else
              return false;
      }
  
      // return all records with only my fields through condition 
      else{
  
          $this-&gt;db-&gt;limit($limit, $start);
          $this-&gt;db-&gt;select($fields);
          $query = $this-&gt;db-&gt;get_where($this-&gt;table, $where);
  
          if ($query-&gt;result() &gt; 0 )
              return $query-&gt;result();
  
          else
              return false;
      }
  }
  
  public function count()
  {
      return $this-&gt;db-&gt;count_all($this-&gt;table);
  }
  
  }
  </code></pre>
  
  <p></p>
  
  <p><strong>view (info.php)</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
   &lt;html lang="en"&gt;
   &lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;title&gt;Applicants - admin&lt;/title&gt;
    &lt;link rel="stylesheet" href="&lt;?php echo base_url('css/normalize.css'); ?&gt; "&gt;
    &lt;link rel="stylesheet" href="&lt;?php echo base_url('css/admin-style.css'); ?&gt; "&gt;
   &lt;/head&gt;
   &lt;body&gt;
     &lt;header&gt;
        &lt;img src="&lt;?php echo base_url('images/path1.png'); ?&gt;" alt=""&gt;
     &lt;/header&gt;
   &lt;section&gt;
      &lt;table class="show-item"&gt;
          &lt;tbody&gt;
              &lt;th&gt;Donor details&lt;/th&gt;
              &lt;tr&gt;
                  &lt;th&gt;Name&lt;/th&gt;
                  &lt;th&gt;Place&lt;/th&gt;
                  &lt;th&gt;Phone&lt;/th&gt;
              &lt;/tr&gt;
              &lt;?php foreach ($data as $key =&gt; $row) {
              ?&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;a href=""&gt;&lt;h3&gt;&lt;?php echo $row-&gt;name;?&gt;&lt;/h3&gt;&lt;/a&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;p&gt;&lt;?php echo $row-&gt;place;?&gt;&lt;/p&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;p&gt;&lt;?php echo $row-&gt;phone;?&gt;&lt;/p&gt;
                  &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;?php } ?&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;?php echo $links ?&gt;
  &lt;/section&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>