我想使用codeigniter显示这个结果
问题描述:
我有一个名为exam_time_table的表。我想得到每个类的时间表。我试图得到结果。但它没有得到。
i have a table named exam_time_table. i want to get the time table of each class. i tried to get the result.but its not getting.
控制器
public function index()
{
$this->load->model('exam_model','exam');
$data['exam_data']=$this->exam->select_data();
$this->load->view('welcome_message',$data);
}
模型
public function select_data() {
$this->db->distinct();
$this->db->select('*');
$this->db->from('exam_time_table');
$this->db->group_by('extt_std');
$query = $this->db->get();
return $query->result();
}
查看
<?php
foreach($exam_data as $exam)
{
echo $exam->extt_id;
echo $exam->extt_sub;
echo $exam->extt_date;
}
?>
答
如果您有两个模型类加载,例如
if you have two model class than load like
$this->load->model(array('exam_model', 'exam'));
或载入
$this->load->model('exam_model');
$this->load->model('exam');