[eluser]puddles[/eluser]
Hi,
Somewhere, I'm losing this...I have read the documentation around Active Record, Controllers, Models, and Views and result generation. Still, I'm having a hard time getting the data retrieved from the database (through the model) to appear in my view. Here is my code:
Model
Code:
<?php
class Standings extends Model {
var $owner;
var $points;
var $datetime;
function Standings()
{
parent::Model();
}
function get_standings()
{
$query = $this->db->get('owner_overall');
return $query->result();
}
}
Controller
Code:
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
// debugging
$this->output->enable_profiler(TRUE);
// loading table library
$this->load->library('table');
// load the header and navigation
$this->load->view('header');
$this->load->view('nav');
// load the Standings model and call function get_standings
$this->load->model('Standings');
$standings = $this->Standings->get_standings();
// load the welcome view and pass it data from Standings model
$this->load->view('welcome', $standings);
// load the footer
$this->load->view('footer');
}
}
/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */
and now the snippet from the view.....
Code:
<div class="span-6">
<!-- this is where I want to view the data returned from db -->
<?php
foreach ($standings as $row)
{
echo $row->Owner;
echo $row->Points;
echo $row->Date_Updt;
}
?>
</div>
Obviously I'm doing this incorrectly as I get both an undefined variable "standings error as well as an "invalid argument supplied foreach()". Can someone point out where I've gone wrong?
Thanks....