Codeigniter search with multiple fields
I've tried to make a search field with two parameters. One for name and the other one for location. But my code returns only the results for the first parameter. Maybe someone could figure out what's wrong.
Below it's my code.
Mode:
public function search_job($keyword, $location){
$query = $this->db->like('name', $keyword)
->like('location', $location)
->or_like('description', $keyword)
->get('jobs');
return $query->result_array();
}
Controller:
public function search_job(){
$location = $this->input->post('location');
$keyword = $this->input->post('keyword');
if ($this->input->post('submit')) {
$this->Job_model->search_job($keyword, $location);
}
}