2017-04-02 103 views
-1

我有这个错误在我看来并不能找出问题出在哪里:未定义的变量(笨)

我的控制器名“问题”:

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)

+0

甲PHP错误遇到 严重性:注意 消息:未定义变量:question_set 文件名:质询/ make_set.php 行号:90 – Rashed

+2

因此,这是线路90 ?? – Sparky

+0

第90行是:foreach($ question_set as $ all_set){ – Rashed

回答

0

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

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); 
} 
+0

不工作..... – Rashed

+0

您是否在构造中加载模型? –

+0

public function __construct(){ parent :: __ construct(); $ this-> load-> model('question_model'); } –