[eluser]tuckee[/eluser]
I retrieve two information from database and put it into an array. In my controller Im not sure how to retrieve the information from the array I have stored my information. Been trying many different ways. Can anyone help me?
My MODEL
Code:
function get_name_address($user_id)
{
$query_str = "SELECT name And address FROM customer WHERE user_id = ?";
$query = $this->db->query($query_str, $user_id);
if($query -> num_rows() > 0 )
{
foreach ($query->result() as $row)
{
$data[] = $row;
}
return $data;
}
}
My CONTROLLER
Code:
function index()
{
$user_id = '3';
$data['row'] = $this->user_model->get_name_address($user_id);
foreach($data as $r) :
$cust_name = $r ->name; //THERE IS ERROR HERE
$cust_address = $r->address; //THERE IS ERROR HERE
endforeach;
echo $cust_name;
echo $cust_address;
}
I got the error "Trying to get property of non-object"
any help is appreciated and Many thanks