未定义的变量(Codeigniter)

时间:2017-04-02 16:48:53

标签: php codeigniter codeigniter-3

我在视图中遇到此错误,无法找出问题所在:

我的控制器名称'问题':

public function show_all_question_set() {
$data = array();
$data['question_set'] = $this->Question_Model->select_all_question_set();
$this->load->view('question/make_set', $data);
}

我的模特名称'Question_Model':

public function select_all_question_set() {
$this->db->select('*');
$this->db->from('tbl_question_set');
$query_result = $this->db->get();
$result = $query_result->result();
return $result;
}

我的观点名称'make_set':

<?php
foreach ($question_set as $all_set) {
?>   
<tr>      
<td align="center">
<a href="#" class="btn btn-default"><em class="fa fa-pencil"></em></a>
<a href="#" class="btn btn-danger"><em class="fa fa-trash"></em></a>
</td>
<td> <?php echo $all_set->exam_name; ?>  </td>
<td> <?php echo $all_set->subject_name; ?> </td>
<td> <?php echo $all_set->set_name; ?> </td>
<td align="center">
<a href="#"class="btn btn-default"><em class="fa fa-book"> দেখুন </em></a>
</td>
</tr>
<?php } ?>

表:tbl_question_set(set_id,exam_name,subject_name,set_name)

2 个答案:

答案 0 :(得分:0)

i think you are getting error because you write model name in capital letter.. please try this. paste this code in your model hopefully it will work..

public function show_all_question_set() {
$data = array();
$data['question_set'] = $this->question_model->select_all_question_set();
$this->load->view('question/make_set', $data);
}

答案 1 :(得分:0)

$这 - &GT;负载&GT;模型(&#39; Question_Model&#39); 如果模型未自动加载,请添加此行以加载模型。