i want to get all the departments if location_id is 3. that means if location id 3 is used i need to get the department_names of cardiology and hair
My controller
public function get_location_departments()
{
$d = $_POST['location'];
$data['departments'] = $this->Hospital_model->get_location_departments($d);
$this->load->view('frontend/ajax_get_departments',$data);
}
My model
public function get_location_departments($d)
{
$this->db->where_in('location_id',$d);
$query=$this->db->get('department')->result();
return $query;
}

Hope this will help you :
You have to query first to get the
departmentand get location_id into an array usingexplodeYour model
get_location_departmentsmethod should be like this :