1
我正在成功從名爲user_model的模型中將數據提取到我的控制器,名稱爲login_controller。在user_model圖所示 :以表格形式在視圖中顯示結果
function fetchData()
{
$this->db->select('DeviceName, DeviceType,RegistrationDateTime,LastUpdateDateTime,LastPushNotificationSent');
$query = $this->db->get('userinfo');
$res=$query->result();
if($res)
{
return $res;
}
else
{
return NULL;
}
}
在我的控制器
我有:
function displayDatabase()
{
$data['tableInfo']=$this->user_model->fetchData();
$this->load->view('adminPanel_view',$data);
}
其中adminPanel_view我這樣做:
<table class="table table-striped table-bordered table-hover table-full- width" id="sample_1">
<thead>
<tr>
<th>Serial No.</th>
<th class="hidden-xs">Device Name</th>
<th>Device Type</th>
<th>RegistrationDateTime </th>
<th>LastUpdateTime</th>
<th>LastPushNotificationSent</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php //print_r ($tableInfo);exit;?>
<?php foreach($tableInfo as $r): ?>
<tr>
<?php echo $r->DeviceName ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
但我無法以表格格式顯示數據。我在做什麼錯更換預定數據顯示這樣
您必須製作正確的表格並設置適當的結果集。 –
謝謝桑傑:)。 –