I'm still learning codeigniter, and i'm trying to create a detail page, so when i click on the detail button on a certain item, it will redirect the user to the detail page of that item. But when i click on it, i don't get any data. What did i do wrong??
The Controller :
public function detail($id){
$data['t_lowongan'] = $this->db->get_where('t_lowongan', array('id_lowongan'=>$id))->row_array();
$this->load->view('detail_lowongan', $data);
}
The detail view :
<div >
<?php foreach($t_lowongan as $lowong){?>
<h5 ><?php echo $lowong->title?></h5>
<?php }?>
</div>
CodePudding user response:
Ok so what i did is, i create the function in the model, the function is called detail_data.
The M_lowongan :
public function detail_data($where, $table){
return $this->db->get_where($table, $where);
}
After that i edit the controller look like this :
$where = array('id_lowongan'=>$id);
$data['t_lowongan'] = $this->m_lowongan->detail_data($where, 't_lowongan')->result();
$this->load->view('detail_lowongan', $data);
And it works :D
CodePudding user response:
try this
public function detail($id){
$data['t_lowongan'] = $this->db->get_where('t_lowongan', ['id_lowongan'=>$id])->result();
$this->load->view('detail_lowongan', $data);
}
and thats it!!! :D