[eluser]IamPrototype[/eluser]
Hey, I got this code and I would like to display all of my entries on my view page.
browse.php (view)
Code:
<h2>Browse All Entries</h2>
<h3><?=$entry['title']?></h3>
<p><?=$entry['body']?></p>
entries.php (controller)
Code:
<?php
class Entries extends Controller {
function __construct()
{
parent::Controller();
$this->table = "entries";
$this->template['module'] = "entries";
$this->load->model('Entries_Model', 'entries', TRUE);
}
function _run($view)
{
$this->template['view'] = $view;
$this->load->vars($this->template);
$this->load->view('loader');
}
function index()
{
$this->template['entry'] = $this->entries->browse();
$this->_run('browse');
}
}
?>
Entries_Model.php (model)
Code:
<?php
class Entries_Model extends Model {
function __construct()
{
parent::Model();
$this->table = "entries";
}
function browse()
{
$this->db->where('active', TRUE);
$this->db->order_by('id', 'desc');
$query = $this->db->get($this->table);
if ($query->num_rows() == 1)
{
return $query->result_array();
}
else
{
return FALSE;
}
}
}
?>
When I go online I get this error.
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined index: title
Filename: entries/browse.php
Line Number: 2
I tried to use
Code:
die(print_r($entry))
in my view and it says I got my data.. but I can't figure out how to show it.
Any kind soul out there?
Greetings!