请帮助我在显示数据时遇到问题,
//Model
public function ambiluser()
{
$user_id = $this->session->userdata('user_id');
$this->db->select('*');
$this->db->from('biodata');
$this->db->where('id', $user_id);
$sec_qry=$this->db->get();
return $result=$sec_qry->result();
}
查看
foreach ($user as $row)
<td><?php echo $row->nik; ?></td>
答案 0 :(得分:0)
首先,您应该检查查询是否返回任何结果!像这样:
if($sec_qry->num_rows() > 0){
return $sec_qry->result();
}
return false;
您认为第二点:
<?php if( $user && !empty($user) ) :?>
<?php foreach( $user as $row ) :?>
<td><?=$row->nik;?></td>
<?php endforeach;?>
<?php endif;?>