我想通过他们的ID获取有关用户的详细数据,但是当我尝试时,我收到错误:undefined variable
。
控制器
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);
}
模型
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();
}
这是视图
<a href="<?php echo site_url('anggota/profil/'.$id_anggota); ?>">
<div class="ui instagram button widget-body">
Kelola Profil
</div>
</a>
视图中的错误为undefined variable id_anggota
。请帮我做点什么。
答案 0 :(得分:0)
当然,你会得到错误,因为你没有在控制器中传递那个id,
$this->data['yourid'] = $this->uri->segment(3);
并将此ID用于您的观点。
答案 1 :(得分:0)
在你的控制器中试试这样的东西
$data['id_anggota'] = $this->uri->segment(3);