title: Codeigniter - How to pass url variable to pagination?
body: <p>I am using <code>Codeigniter</code> pagination library with first time. Now when user search anything from search form, I want to pass URL variable to pagination at the end of URL like this <code>http://localhost/sitename/brand/campaigns/6/?search="hello"</code> for maintain search results on second page.</p>
  
  <p>Any idea how to do with codeigniter?</p>
  
  <p>Here is my code:</p>
  
  <h2>Form</h2>
  
  <pre><code>&lt;form name="frmSearch" id="frmSearch" method="get" action="&lt;?php echo base_url(); ?&gt;brand/campaigns"&gt;
      &lt;input type="text" name="search" id="search" placeholder="Search campaigns" onchange="return trim(this)"&gt;
      &lt;button type="submit" class="search-submit"&gt;&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <h2>Controller (campaigns_list.php)</h2>
  
  <pre><code>public function __construct(){
      parent::__construct();
      $this-&gt;load-&gt;model('Campaigns_list_model');
      $this-&gt;load-&gt;library('pagination');
  }
  
  public function index($offset=0){
      IsNotLoggedIn(); // Check if a user is not logged in
  
      // For SEO
      $data['meta_title'] = 'Search';
      $data['meta_descripton'] = '';
      $data['meta_keywords'] = '';
  
      // Pagination code for campaigns code start
      $config['total_rows'] = $this-&gt;Campaigns_list_model-&gt;TotalCampaigns();
  
      // Check status value is number
      $status = $this-&gt;uri-&gt;segment(3);
      if(!ctype_digit($status)){
          $status = "1";
      }
  
      $config['base_url'] = base_url()."brand/campaigns/".$status;
      $config['per_page'] = 6;
      $config['uri_segment'] = '4';
  
      $config['full_tag_open'] = '&lt;div class=""&gt;&lt;ul class="pagination pull-right"&gt;';
      $config['full_tag_close'] = '&lt;/ul&gt;&lt;/div&gt;';
  
      $config['first_link'] = '« First';
      $config['first_tag_open'] = '&lt;li class="prev page"&gt;';
      $config['first_tag_close'] = '&lt;/li&gt;';
  
      $config['last_link'] = 'Last »';
      $config['last_tag_open'] = '&lt;li class="next page"&gt;';
      $config['last_tag_close'] = '&lt;/li&gt;';
  
      $config['next_link'] = 'Next →';
      $config['next_tag_open'] = '&lt;li class="next page"&gt;';
      $config['next_tag_close'] = '&lt;/li&gt;';
  
      $config['prev_link'] = '← Previous';
      $config['prev_tag_open'] = '&lt;li class="prev page"&gt;';
      $config['prev_tag_close'] = '&lt;/li&gt;';
  
      $config['cur_tag_open'] = '&lt;li class="active"&gt;&lt;a href=""&gt;';
      $config['cur_tag_close'] = '&lt;/a&gt;&lt;/li&gt;';
  
      $config['num_tag_open'] = '&lt;li class="page"&gt;';
      $config['num_tag_close'] = '&lt;/li&gt;';
  
      $this-&gt;pagination-&gt;initialize($config);
      $query = $this-&gt;Campaigns_list_model-&gt;GetCampaigns(6, $this-&gt;uri-&gt;segment(4));
  
      $data['Campaigns'] = null;
  
      if($query){
          $data['Campaigns'] =  $query;
      }
      // Pagination code for campaigns code end
  
      $this-&gt;load-&gt;view('include/brand_header', $data);
      $this-&gt;load-&gt;view('brand/campaigns_list', $data);
      $this-&gt;load-&gt;view('include/brand_footer');
  }
  </code></pre>