skip to Main Content

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


  1. Chosen as BEST ANSWER

    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


  2. 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!!! 😀

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search