title: search and pagination on codeigniter
body: <p>guys</p>
  
  <p>I try to create search with pagination. i can do it, when i go to second page isn't problem but when i go third page data is lose.
  please help me. this is my code of controller :</p>
  
  <pre><code>function fast_search() {
  
      $data = array(
          'reason'           =&gt; $this-&gt;input-&gt;post('reason'),
          'shahr'            =&gt; $this-&gt;input-&gt;post('shahr'),
          'file_type'        =&gt; $this-&gt;input-&gt;post('file_type'),
          'region'           =&gt; $this-&gt;input-&gt;post('region'),
          'neighbourhood'    =&gt; $this-&gt;input-&gt;post('neighbourhood'),
          'under_build_area' =&gt; $this-&gt;input-&gt;post('under_build_area'),
          'user_type'        =&gt; $this-&gt;input-&gt;post('user_type')
      );
  
      $this-&gt;session-&gt;set_flashdata($data);
  
      /*-------------------------------------------------------*/
      $page = ($this-&gt;uri-&gt;segment(4)) ? $this-&gt;uri-&gt;segment(4) : 0;
  
      if ($page == 0) 
      {
          $config = array();
          $config['base_url']    = base_url() . 'file/fast_search/page';
          $config['per_page']    = 9;
          $config['uri_segment'] = 4;
          $config['total_rows']  = count($this-&gt;file_model-&gt;fast_search($data));
          $this-&gt;pagination-&gt;initialize($config);
  
          $data['results'] = $this-&gt;file_model-&gt;fast_search($data, $config['per_page'], $page);
          $data['links']   = $this-&gt;pagination-&gt;create_links();
  
      } else {
  
          $this-&gt;session-&gt;keep_flashdata('reason');
          $this-&gt;session-&gt;keep_flashdata('shahr');
          $this-&gt;session-&gt;keep_flashdata('file_type');
          $this-&gt;session-&gt;keep_flashdata('region');
          $this-&gt;session-&gt;keep_flashdata('neighbourhood');
          $this-&gt;session-&gt;keep_flashdata('under_build_area');
          $this-&gt;session-&gt;keep_flashdata('user_type');
  
          $result_data = array(
              'reason'           =&gt; $this-&gt;session-&gt;flashdata('reason'),
              'shahr'            =&gt; $this-&gt;session-&gt;flashdata('shahr'),
              'file_type'        =&gt; $this-&gt;session-&gt;flashdata('file_type'),
              'region'           =&gt; $this-&gt;session-&gt;flashdata('region'),
              'neighbourhood'    =&gt; $this-&gt;session-&gt;flashdata('neighbourhood'),
              'under_build_area' =&gt; $this-&gt;session-&gt;flashdata('under_build_area'),
              'user_type'        =&gt; $this-&gt;session-&gt;flashdata('user_type')
          );
  
          $config = array();
          $config['base_url']    = base_url() . 'file/fast_search/page';
          $config['per_page']    = 9;
          $config['uri_segment'] = 4;
          $config['total_rows']  = count($this-&gt;file_model-&gt;fast_search($result_data));
          $this-&gt;pagination-&gt;initialize($config);
  
          //$this-&gt;dvd($result_data);
          $data['results'] = $this-&gt;file_model-&gt;fast_search($result_data, $config['per_page'], $page);
          $data['links']   = $this-&gt;pagination-&gt;create_links();
      }
  
      /*-------------------------------------------------------*/
  
      //$this-&gt;dvd($data['links']);
  
      if ($data['results'] != FALSE) 
      {
          $data['agency_nums']      = $this-&gt;user_model-&gt;get_registered_agency();
          $data['updated_agencies'] = $this-&gt;user_model-&gt;get_uplated_agencies();
          $data['count_files']      = $this-&gt;file_model-&gt;count_files();
  
          $this-&gt;load-&gt;view('fast_search', $data);
          //return $data;
      } else {
          $data['error']            = 'No Result !';
          $data['agency_nums']      = $this-&gt;user_model-&gt;get_registered_agency();
          $data['updated_agencies'] = $this-&gt;user_model-&gt;get_uplated_agencies();
          $data['count_files']      = $this-&gt;file_model-&gt;count_files();
          $this-&gt;load-&gt;view('fast_search', $data);
      }
  }
  </code></pre>
  
  <p>I use session function like : 
  $this->session->set_flashdata($data);
  $this->session->keep_flashdata('reason');</p>