I have a codeigniter search form which includes a dropdown list (Car) and a checkbox array (Car types). I was using POST method to get values from database but post method conflicts with pagination so I decided to use GET method. But now my 'if' statement does not work and it returns me 'else' scenario (i.e. 'search_nok' page with a message "Please select your search options"). Could you please check my code and help me to find the mistake.
Here is my controller
public function search($offset = 0) {
$limit = 5;
$this->load->library('form_validation');
$this->load->model('model_x');
$this->form_validation->set_rules('car', 'Car','required');
$this->form_validation->set_rules('types', 'Car Type','required');
if($this->form_validation->run()) {
$car= $this->input->get('car');
$types = $this->input->get('types');
$this->load->library('pagination');
$config['base_url'] = 'http://localhost/abc/cont/search/';
// 'http://localhost/abc' is my base url
$config['total_rows'] = 14;
$config['per_page'] = 5;
$data['pagination'] = $this->pagination->initialize($config);
if ($this->model_x->did_search($car, $types, $limit, $offset)){
$data["results"] = $this->model_x->did_search($car, $types, $limit, $offset);
$this->load->view("search_ok",$data);
}
}
else
{
$data['message'] = 'Please select your options.';
$this->load->view("search_nok",$data);
}
}