title: Codeigniter: How to paginate search results
body: <p>When I search a keyword it just show me all the like in the database. Then if I click the next in the pagination. The keyword is lost. How do i maintain the searched keyword if i click the next button in pagination? </p>
  
  <p>Controller:</p>
  
  <pre><code>public function info($offset=0)
  {       
  $filter = $this-&gt;input-&gt;get("filter");
      $limit = 5;
      $this-&gt;load-&gt;library('pagination');
      $filter = $this-&gt;input-&gt;get("filter");
  
  
      $this-&gt;db-&gt;where('is_valid','1');
      $this-&gt;db-&gt;like('requested_by',$filter);
      $search = $this-&gt;input-&gt;get("search");
        $page = $this-&gt;uri-&gt;segment(3);
      $config["base_url"] = "/ticketing/index.php/ticketing/info/";
  
      $config['total_rows'] = $this-&gt;db-&gt;count_all_results('db_ticketing.tr_ticket');
      $config['per_page'] = $limit;
  //  $config['base_url'] = ("/ticketing/index.php/ticketing/info/");
      $config['use_page_numbers'] = false;
      $config['num_links'] = 4;
  
  
      $config['first_link'] = 'First';
      $this-&gt;pagination-&gt;initialize($config);
      $data['pagination'] = $this-&gt;pagination-&gt;create_links();
  
  
  
  $data['ticket_list'] = $this-&gt;ticketing_mdl-&gt;get_all_ticket( $limit, $offset);
  
  
  
      $this-&gt;load-&gt;view('ticketing/header');
      $this-&gt;load-&gt;view('ticketing/left_menu');
      $this-&gt;load-&gt;view('ticketing/info',$data);
  }
  </code></pre>
  
  <p>Model</p>
  
  <pre><code>function get_all_ticket($limit,$offset)
  {
      if($this-&gt;input-&gt;get('search')){
       $match = $this-&gt;input-&gt;get('search');
          $sql = "SELECT * FROM db_ticketing.tr_ticket WHERE requested_by LIKE '%$match%' limit $limit offset  $offset";
          return $this-&gt;db-&gt;query($sql);
  
      }
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;form method="get" action=""&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Search:&lt;/td&gt; 
                      &lt;td&gt;&lt;input type="text" name="search" /&gt;&lt;/td&gt;
  
                  &lt;/tr&gt;
                  &lt;/form&gt; 
  </code></pre>