我對codeigniter是相當新的,似乎無法得到這個問題的持有,總之我有問題了解CodeIgniter框架之間的數據流。所有我想要顯示的使用情態動詞,並在視圖中顯示從數據庫中獲取數據..如何保存和顯示值從模態到數據庫使用codeigniter查看
在我的控制器中的代碼是:
$unitData =$this->ClientUnit->getBlockUnits($client_block_ID);
foreach ($unitData->result() as $row){
for ($i=0; $i < 3; $i++) {
$client_unit_name[$i] = $row->client_unit_name[$i];
$unit_owner_name[$i] = $row->unit_owner_name[$i];
}
}
$data['client_unit_name'] = $client_unit_name;
$data['unit_owner_name'] = $unit_owner_name;
$this->load->view('newblock_unit',$data);
我的樣式文件是:
function getBlockUnits($client_block_ID) {
$query = $this->db->query('SELECT * FROM client_units where client_block_ID="'.$client_block_ID.'"');
return $query;
}
由於你可以看到,從我的模態和控制器代碼,問題是因爲多行返回,目前我只得到所有輸出中的最後一行視圖,而不是單個行...
你的答案几乎是正確的,但我已經得到了答案,你也重定向我的答案我一直在尋找,但因爲我是新來的StackOverflow,我不能回答只是尚未:P 實際我忘了提及在for循環中要更改的行,如您在以下提到的鏈接底部所述: $ row = $ unitData-> row($ i); – 2013-04-09 08:33:00
@blogger如果你沒有把我的標記標記爲正確,那麼只需關閉線程或者對此做些什麼...... – jakobhans 2013-09-18 16:05:40