php - Everything is ok but it says Severity: Notice Message: Undefined variable: categories -
//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 $c):?> <tr> <td><?php echo $c['id'];?></td> <td><?php echo $c['phone'];?></td> <td><?php echo $c['name'];?></td> </tr> <?php endforeach;?>
this code. every time says undefined variable , invalid argument supplied foreach. please
you need pass $data
array view controller
$data['categories'] = $this->registrant_model->getalldepartment(); $this->load->view('systemadminuser/registrant', $data);// pass $data view
Comments
Post a Comment