我成功地将名为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>
&#13;
答案 0 :(得分:0)
请在您的视图文件中尝试此操作...
<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>
<td><?php echo $r->no ?></td>
<td><?php echo $r->DeviceName ?></td>
<td><?php echo $r->DeviceType ?></td>
<td><?php echo $r->RegistrationDateTime ?></td>
<td><?php echo $r->LastUpdateTime ?></td>
<td><?php echo $r->LastPushNotificationSent ?></td>
<td><?php echo $r->Actions ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
希望这会对你有所帮助。