【发布时间】:2015-07-15 05:24:45
【问题描述】:
我想回显数组,来自同一个表但不同的 id,来自 db,Codeigniter 中超过 1 行。
型号-----------------
public function DeviceRowInfo($mobno)
{
$this->db->select('*');
//$this->db->where("mobile_no", $mobno);
$this->db->where("profile_id", $profile_id);
$pid_device_count_query = $this->db->get("ptt_device");
if ($pid_device_count_query->num_rows() > 0)
{
//foreach ($pid_device_count_query->result_array() as $count_rows)
// {
return $pid_device_count_query->row_array();
echo $row['device_identifier'];
echo $row['device_os_version'];
// }
}
else
{
return 0;
}
}
控制器---------------------------------------------- -----
public function ViewDevices()
{
$data['user_device_row'] = $this->security_model->DeviceRowInfo($mobno);
$data['user_profile_row'] = $this->security`enter code here`_model->ProfileRowInfo($mobno);
$data['device_count'] = $this->security_model->DeviceCountInfo($mobno);
}
查看---------------------------------------------- --------------------
foreach( $user_device_row as $devi_row )
{
?>
<table class="table table-bordered text-center">
<tbody>
<tr>
<td>Device Count</td>
<td><?php echo $device_count; ?></td>
</tr>
<tr>
<td>IMEI</td>
<td><?php echo $devi_row[0]['device_identifier']; ?></td>
</tr>
<tr>
<td>OS Versions</td>
<td><?php echo $devi_row[0]['device_os_version']; ?></td>
</tr>
<tr>
<td>Register On</td>
<td><?php foreach($user_profile_row as $devi_pro_row)
{
// set default timezone
date_default_timezone_set('Asia/Bangkok');
// timestamp
$timestamp = $devi_pro_row[0]['registerd_on'];
// output
echo date('d/m/Y',$timestamp);
} ?></td>
</tr>
<tr>
<td>Last Logged in</td>
<td><?php echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"//$devi_row['device_identifier']; ?></td>
</tr>
<tr>
<td>Active Device</td>
<td><?php echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"//$devi_row['device_identifier']; ?></td>
</tr>
</tbody>
【问题讨论】:
-
再描述一点
-
我尝试从数据库表中打印数据,该数据在不同的行中具有相同的关键字,因此我想将它们的每一行打印到我的视图页面。所以在我的视图页面中将显示表取决于具有相同搜索关键字的行。
标签: mysql codeigniter