[eluser]trickymh[/eluser]
Hello,
I apologise if this has been covered before. I have searched, but only found one similar question, and the fix didn't work for me.
All I want to do is retrieve the value of a field, and use it in a view.
My Controller:
Code:
function index()
{
$this->load->model('data_model');
$data['resources'] = $this->data_model->get_resource(); // get info from table
$data['no_props'] = $this->db->count_all('resources'); // count no. of rows in table
$this->load->view('home_view', $data);
}
My model code:
Code:
function get_resource()
{
$results = $this->db->get('resources')->result();
return $results;
}
And my view code (well, the important bit)
Code:
<div><?php echo $results->name;?></div>
where 'name' is the name of the field. For testing's sake there is only one row in the 'resources' table.
I get the following errors:
undefined variable: results
trying to get property of non-object
I have tried so many different syntaxes and ways of doing this. I'm going mental hehe.
Thanks for any help