2017-04-02 102 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'); } –