CodeIgniter Forums

Full Version: Search & paginate
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Mr.President[/eluser]
I am stuck on a search I have a form in the view in which there is a
search form with more than 10 fields currently I am using the session variable to store
the search terms and retrieve them on every page clicks !

Please advice am I doing the right thing ?

Code:
//advance search
public function searchbox($start_row='')
{
  $per_page = 5;
  if(trim($start_row=='')){
   $start_row=0;
  }
  
  session_start();
  $getdata = $this->input->get(NULL, TRUE);
  if($getdata == ''){
   $getdata = $_SESSION['gdata'];
  }else{
   $_SESSION['gdata']=$getdata;
  }
  
  $num_rows= $this->vehicle_model->getvehicleSearchBox_numrows($getdata);
  
  $this->load->library('pagination');
  $config['base_url'] = base_url().'index.php/site/searchbox/';
  $config['total_rows'] = $num_rows;
  $config['per_page'] = $per_page;
  $config['uri_segment'] = 3;
  $this->pagination->initialize($config);
  
  $data['pagination_links'] = $this->pagination->create_links();
  $data['search'] = $this->get_adavancesearch($getdata, $start_row, $per_page);  
  $data['header'] = $this->load->view('header','',true);
  $data['menu'] = $this->makemenu();
  $data['searchform'] = $this->searchforms();
  $this->load->view('vehiclerow_layout',$data);
}