0

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 class="card-body">
 <?php foreach($t_lowongan as $lowong){?>
  <h5 class="card-title"><?php echo $lowong->title?></h5>
 <?php }?>
</div>

2 Answers 2

0

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

0
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.