I want to get detailed data about a user by their id but when I try, I get an error: undefined variable
.
controller
function index()
{
$this->data['prodi'] = $this->mprodi->get_prodi();
$id_anggota = $this->uri->segment(3);
$this->load->model('mdaftar');
$this->data['anggota'] = $this->mdaftar->get_daftar();
$this->data['detail'] = $this->mdaftar->get_daftar_detail($id_anggota);
dump($this->mdaftar->get_daftar_detail($id_anggota));
echo '<pre>'. $this->db->last_query() . '</pre>' ;
$this->data['title'] ='UKM Taekwondo';
$this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
$this->data['contents'] = $this->load->view('anggota/profil', $this->data, true);
$this->load->view('template/wrapper/anggota/wrapper_ukt',$this->data);
}
model
function get_daftar_detail($id_anggota)
{
$this->db->select('*');
$this->db->from('mahasiswa');
$this->db->join('pendaftaran_anggota','pendaftaran_anggota.nim = mahasiswa.nim','left');
$this->db->where('id_anggota',$id_anggota);
$this->db->join('prodi','prodi.id_prodi = mahasiswa.id_prodi','left');
$data = $this->db->get();
return $data->row();
}
and this is the view
<a href="<?php echo site_url('anggota/profil/'.$id_anggota); ?>">
<div class="ui instagram button widget-body">
Kelola Profil
</div>
</a>
error is undefined variable id_anggota
in the view. Please help me with what to do.
Ofcourse you will get error because you didn't passed that id in controller ,
$this->data['yourid'] = $this->uri->segment(3);
And use this id to your view.
在您的控制器中尝试这样的事情
$data['id_anggota'] = $this->uri->segment(3);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.