//controller:
private function getAll() {
    $data['categories'] = $this->registrant_model->getAllDepartment();
    $this->load->view('SystemAdminUser/registrant', $data);
}
//model:
public function getAllDepartment() {
    $this->db->select('*')->from('patient_db');
    $query = $this->db->get();
    return $query->result_array();
}
//view:
<?php foreach($categories as $c):?>
    <tr>
        <td><?php echo $c['id'];?></td>
        <td><?php echo $c['phone'];?></td>
        <td><?php echo $c['name'];?></td>
    </tr>
<?php endforeach;?>
this is the code. every time it says undefined variable and Invalid argument supplied for foreach. please help
 
    