我想从同一个表中回显数组,但不同的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>
答案 0 :(得分:0)
//型号代码
function startHandlingFromSubmission(e){
if(e.keyCode===13){ //To check enter event
$(e.target).blur();
}
if(e.keyCode===0){ //To check span event
setTimeout(function() {
handleFromPlaceSubmission(e);
}, 200);
}
}
function handleFromPlaceSubmission(e){
//This is the actual function which we desire to call
if(e.keyCode === 0){ //executing only in case of blur event
// your code goes here
}
}
//控制器代码
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)
{
return $pid_device_count_query->result_array();
}
else
{
return false;
}
}
}
//查看代码
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);
//Load your view here
$this->load->view('your_view_name',$data);
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['device_identifier']; ?></td>
希望这对你有用