[eluser]bigtimslim[/eluser]
My site has a header that I want to print a random entry from a db table in. How would you tackle this? I tried just directly loading the model and printing the result and such in the header view, but am getting an error: "Call to a member function get_wally() on a non-object"
Code:
Model function:
function get_wally()
{
$query = $this->db->query("SELECT wally_says FROM wally ORDER BY RAND() LIMIT 1");
return $query->row();
}
from View:
<div id="wallysays" class="round">
<?php
$this->load->model('Wally_model');
$wally = $this->wally_model->get_wally();
echo $wally->wally_says;
?>
</div>
I must be doing something stupid here. Help me out?