Codeigniter Set variable Codeigniter Set variable codeigniter codeigniter

Codeigniter Set variable


CodeIgniter uses extract to generate the variables in the view page. So, you'll have to pass in an associative array as the second argument of the $this->load->view() call. In this case, if you want the variable to be named data, you'll have to pass in an array with the element key being data and the value being the data you retrieved from the model.

$data = array('data' => $this->userdata_model->desc($id));$this->load->view('category/description', $data);


You can do like this

 $data["ids"] = $this->userdata_model->desc($id); $this->load->view('category/description', $data);

in your view you can access the variable using

$ids


$data is an array, contains all information, which you want show on view page.

In controller:

$this->load->model( 'userdata_model' );// .. other code$data = array(        'description' => $this->userdata_model->desc($id)    );$this->load->view('category/description', $data );

In view:

<div><?php echo $description; ?></div>