0
在我的控制器我要通過數據庫這段代碼迴路和返回數據通過數據庫循環並返回相關數據
$faultgroup = $this->booking_model->Get_Fault_Group_Display($grouptype);
$data['Get_Fault_Group_Display'] = $faultgroup; $getresults = array();
$data['get_fault_group_data'] = array();
foreach ($faultgroup as $key) {
$show = $key->Showgroup;
$getresults = $this->booking_model->get_fault_group_data($grouptype,$show);
$data['get_fault_group_data'] = $getresults ;
}
在我看來,我必須通過這個代碼迴路每個記錄與來自數據庫的特定羣組類型和顯示記錄(to_do_item)匹配的羣組類型
<?php if (! is_null($Get_Fault_Group_Display)): ?>
<?php if (count($Get_Fault_Group_Display)): ?>
<?php foreach ($Get_Fault_Group_Display as $result): ?>
<?php echo $result->Showgroup; ?>
<?php foreach ($get_fault_group_data as $key) :?>
<?php echo $key->to_do_item; ?>
<?php endforeach ?>
<?php endforeach ?>
<?php else: ?>
<?php endif ?>
我的問題是隻有在所有的grouptypes顯示的最後一行,因爲循環保持與新的$ getresults
,我如何通過 $數據環[ 'get_fault_group_data'] [] 的看法? –
我編輯了回覆,檢查是否有效 – costa