CodeIgniter Forums

Full Version: Undefined index: id problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
I have a problem in accessing data.After restarting the wampserver there is a problem in query result.
Controller;
function category(){
$data = $this->electronics_model->general();
$data['query'] = $this->electronics_model->get_category();
$this->load->view('includes/test',$data);

}
Model:
function get_category(){
$this->load->database();
$q = $this->db->get("category");

return $q->result_array();

}
View:

<?php

foreach ($query as $row){

echo $row['cat_id'];
echo $row['cat'];

}

?>
ERROR Comes here

A PHP Error was encountered

Severity: Notice

Message: Undefined index: id

Filename: includes/test.php

Line Number: 14