2021年3月19日星期五

Codeigniter click url with id to view page

I try to get a variable working on my next page.

In controller.php I have the following:

        $buttons .= '<a href="'.base_url('klant/profiel/'.$value['id']).'" class="btn btn-default"><i class="fa fa-address-book"></i></a>';   

And the part that is about the profiel view in controller I have this:

public function profiel($id = null)   {      $data = $this->klant_model->getKlantData($id);        echo json_encode($data);        $this->render_template('klant/profiel', $this->data);  }  

In my model I have this:

public function getKlantData($id = null)  {      if($id) {          $sql = "SELECT * FROM klant WHERE id = ?";          $query = $this->db->query($sql, array($id));          return $query->row_array();      }        $sql = "SELECT * FROM klant";      $query = $this->db->query($sql);      return $query->result_array();  }  

And in my view I have this:

 <?php echo $data['bedrijf']; ?>  

I just want to echo out each colum of the row I have selected in the beginning.

This error I get:

Message: Undefined variable: value

(Also afraid to post here, to not get downvoted or.... :-( )

https://stackoverflow.com/questions/66717041/codeigniter-click-url-with-id-to-view-page March 20, 2021 at 08:07AM

没有评论:

发表评论