title: Two lots of pagination with codeigniter on one page
body: <p>I have to lots of paginations one lot is for my user's results and the other is for my question results.</p>
  
  <p>When I am on link 3 on my question results it also switches the results on users list pagination.</p>
  
  <blockquote>
    <p>Question if I click on the questions pagination links how can I make sure it does not affect the results of the user's list.</p>
  </blockquote>
  
  <p>I have tried this <a href="https://stackoverflow.com/questions/11154750/best-way-to-do-multiple-pagination-on-one-page-in-codeigniter">Best way to do multiple pagination on one page in codeigniter</a> does not work </p>
  
  <p>As you can see in image below because I am on questions list page 3 it has effected the users list</p>
  
  <p><a href="https://i.stack.imgur.com/4vRPp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4vRPp.png" alt="enter image description here"></a></p>
  
  <pre><code>&lt;?php
  
  class Dashboard extends MY_Controller {
  
      public $data = array();
  
      public function __construct() {
          parent::__construct();
          $this-&gt;load-&gt;model('user/user_model');
          $this-&gt;load-&gt;model('forum/question_model');
  
          $this-&gt;load-&gt;library('pagination');
      }
  
      public function index() {       
          $this-&gt;data['title'] = 'Dashboard';
          $this-&gt;data['is_logged'] = $this-&gt;session-&gt;userdata('is_logged');
  
          $config1['base_url'] = base_url('dashboard/');
          $config1['total_rows'] = $this-&gt;user_model-&gt;total_users();
          $config1['per_page'] = 2;
          $config1['uri_segment'] = 2;
          $config1['num_links'] = 200;
          $config1['use_page_numbers'] = FALSE;
          $config1['prefix'] = 'u_';
  
          $pagination1 = new CI_Pagination();
          $pagination1-&gt;initialize($config1);
  
          $this-&gt;data['pagination1'] = $pagination1-&gt;create_links();
  
          $page_segment1 = explode('_', $this-&gt;uri-&gt;segment(2));
  
          $page1 = ($this-&gt;uri-&gt;segment(2)) ? $page_segment1[1] : 0;
  
          $this-&gt;data['users'] = array();
  
          $users = $this-&gt;user_model-&gt;get_users($config1['per_page'], $page1);
  
          foreach ($users as $user) {
              $this-&gt;data['users'][] = array(
                  'user_id' =&gt; $user['user_id'],
                  'username' =&gt; $user['username'],
                  'status' =&gt; ($user['status']) ? 'Enabled' : 'Disabled',
                  'warning' =&gt; '0' . '%',
                  'date' =&gt; date('d-m-Y H:i:s A', $user['date_created_on']),
                  'href' =&gt; site_url('user/profile/') . $user['user_id']
              ); 
          }
  
          // Questions Pagination &amp; Results   
  
          $config2['base_url'] = base_url('dashboard/');
          $config2['total_rows'] = $this-&gt;question_model-&gt;total_questions();
          $config2['per_page'] = 2;
          $config2['uri_segment'] = 2;
          $config2['num_links'] = 200;
          $config2['use_page_numbers'] = FALSE;
          $config2['prefix'] = 'q_';
  
          $pagination2 = new CI_Pagination();
          $pagination2-&gt;initialize($config2);
  
          $this-&gt;data['pagination2'] = $pagination2-&gt;create_links();
  
          $page_segment2 = explode('_', $this-&gt;uri-&gt;segment(2));
  
          $page2 = ($this-&gt;uri-&gt;segment(2)) ? $page_segment2[1] : 0;
  
          $this-&gt;data['questions'] = array();
  
          $questions = $this-&gt;question_model-&gt;get_questions($config2['per_page'], $page2);
  
          foreach ($questions as $question) {
              $this-&gt;data['questions'][] = array(
                  'user_id' =&gt; $question['user_id'],
                  'title' =&gt; $question['title']
              ); 
          }
  
          $this-&gt;data['navbar'] = $this-&gt;load-&gt;view('common/navbar', $this-&gt;data, TRUE);
          $this-&gt;data['header'] = $this-&gt;load-&gt;view('common/header', $this-&gt;data, TRUE);
          $this-&gt;data['footer'] = $this-&gt;load-&gt;view('common/footer', '', TRUE);
  
          $this-&gt;load-&gt;view('common/dashboard', $this-&gt;data);
  
      }
  }
  </code></pre>
  
  <p>Question Model</p>
  
  <pre><code>&lt;?php
  
  class Question_model extends CI_Model {
  
      public function get_questions($limit, $start) {
          $this-&gt;db-&gt;select('*');
          $this-&gt;db-&gt;from('questions q');
          $this-&gt;db-&gt;join('users u', 'u.user_id = q.user_id', 'left');
          $this-&gt;db-&gt;limit($limit, $start);
          $query = $this-&gt;db-&gt;get();
          return $query-&gt;result_array();
      }
  
      public function total_questions() {
          return $this-&gt;db-&gt;count_all("questions");
      }
  }
  </code></pre>
  
  <p>Users Model</p>
  
  <pre><code>&lt;?php
  
  class User_model extends CI_Model {
  
      public function get_users($limit, $start) {
          $this-&gt;db-&gt;select('u.status, u.date_created_on, ud.*');
          $this-&gt;db-&gt;from('users u', 'left');
          $this-&gt;db-&gt;join('users_userdata ud', 'ud.user_id = u.user_id', 'left');
          $this-&gt;db-&gt;limit($limit, $start);
          $query = $this-&gt;db-&gt;get();
          return $query-&gt;result_array();
      }
  
      public function total_users() {
          return $this-&gt;db-&gt;count_all("users");
      }
  
  }
  </code></pre>