当我想从每个这个数组中获取来自数据库的信息来访问数组时,我得到了这个错误Undefined variable nik
查看
foreach ($data as $user) {
$id_user = $user->id_user;
$nama = $user->nama;
$nik = $user->nik;
echo $nik;
$alamat = $user->alamat;
$no_telp = $user->no_telp;
$pass = md5($user->password);
$name = $user->name;
}
控制器
public function user_akun_detail() {
$id_user = $this->input->get('id');
$detail['data'] = $this->Madmin->user_akun_detail($id_user);
$this->load->view('admin/Detail_user_pemilih', $detail);
$this->session->set_flashdata('id_user', $id_user);
}
模型
public function user_akun_detail($id_user) {
$this->db->select('*');
$this->db->from('akun');
$this->db->join('detail_user', 'detail_user.id_user = akun.id_user');
$this->db->join('image_user', 'akun.id_user = image_user.id_user');
$this->db->where('akun.id_user', $id_user);
$query = $this->db->get();
return $query->result();
}