|
如图,十分苦恼,不知道哪里出了问题,求大佬们帮助
源码:【视图】
<tbody>
<?php foreach($stu as $item): ?>
<tr>
<td><?php echo $item['stu_id'] ?></td>
<td><?php echo $item['stu_name'] ?></td>
<td><?php echo $item['stu_sex'] ?></td>
<td><?php echo $item['stu_major'] ?></td>
<td><?php echo $item['stu_group'] ?></td>
<td><?php echo $item['grade'] ?></td>
<td></td>
<td><a href="<?php echo site_url('index/student/stu_mod') ?>" >修改</a></td>
<td><a href="<?php echo site_url('index/student/stu_del') ?>" >删除</a></td>
</tr>
<?php endforeach;?>
</tbody>
【模型】
public function select(){
$res3="SELECT * FROM `student_info`";
$result3 = $this->db->query($res3)->result_array();
return $result3;
}
【控制器】
public function stu_inf(){
$this->load->model('students','students');
$data['stu'] = $this->students->select();
$this->load->view('index/student.html',$data);
}
报错:Undefined variable: stu
|
|