so i'm having this problem all the time and I still can't figure out what the problem really is. Can anyone help me with this?
my model:
public function get_student(){
$query = $this->db->get('tbl_student');
return $query->result();
}
my controller:
public function view_list(){
$this->load->model('student_view_model');
$data['results'] = $this->student_view_model->get_student();
$this->load->view('view_student_list', $data);
}
my view:
<?php foreach($results as $row) { ?>
<tr>
<td><?php echo $row->student_fname ; ?></td>
<td><?php echo $row->student_course ; ?></td>
<td><?php echo $row->student_company ; ?></td>
</tr>
<?php } ?>
my error:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: results
Filename: views/view_student_list.php
Line Number: 26
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/view_student_list.php
Line Number: 26
my question is why does my variable $results undefined? I just copied it from my previous code and my previous code works and this one doesn't.