[eluser]the_unforgiven[/eluser]
Now I HAVE another error:
Severity: Notice
Message: Trying to get property of non-object
Filename: views/events.php
Line Number: 74
My view file:
Code:
<div id="events">
<?php echo "<pre>";
print_r($lhsList);
echo "</pre>";
?>
<?php foreach($events as $item) : ?>
<h3><?php echo anchor('events/getAll/'.$list->id); ?></h3>
<?php endforeach; ?>
</div>
</div>
<!-- content left -->
<!-- content right -->
<div id="content-right">
<h2>Events/Rideouts</h2>
<div id="display">
<?php foreach($events as $item) : ?>
<?php echo $item['description']?>
<?php endforeach; ?>
</div>
<div class="clear"></div>
</div>
<!-- content right -->
Controller File:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Events extends Controller {
function __construct() {
parent::__construct();
$this->load->helper('url');
$this->load->model('Eventsmodel');
$this->config->load('mcd');
}
function index() {
// Get UL list for navigation
$data['events'] = $this->Eventsmodel->getLeft();
//$controller = $this->uri->segment(1);
//$data['events'] = $this->Eventsmodel->getLeft($controller);
$this->load->view('events', $data);
}
function getDetails($id = null) {
if($id != null){
$data['mainContents'] = $this->Eventsmodel->getRightDetails($id);
}
$this->load->view('events', $data);
$controller = $this->uri->segment(1);
$data['events'] = $this->Eventsmodel->getRHSDetails(2);
$this->load->view($controller, $data);
}
}
/* End of file events.php */
/* Location: ./application/controllers/events.php */
Model File
Code:
<?php
class Eventsmodel extends Model {
function __construct()
{
parent::__construct();
// load database class and connect to MySQL
$this->load->database();
}
function getLeft(){
$query = $this->db->select('id', 'title', 'created_on');
$query = $this->db->where('published', 'active');
$query = $this->db->get('mcd_events');
return $query->result();
}
function getRightDetails($id){
$qs = "SELECT description FROM mcd_events WHERE id=$id";
$this->load->view('events');
}
function getRHSDetails($id){
if($id){
$this->Eventsmodel->getRightDetails($id);
$this->load->view('events');
}
}
}
?>
I have followed through what has been said in previous posts but still struggling to find where I have gone wrong and why it's not doing what I logically think it should be doing.