Hi guys,
Could someone please help me with a small problem i am having?
I want to display a message if there are no entry's in a table but for some reason i cant get this right.
Here is my Controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Landing extends CI_Controller{
public function __construct()
{
parent::__construct();
$this->load->model('Ksm_model');
}
public function index(){
$data['title'] = "Welcome";
$data['main_content'] = 'home';
$data['events'] = $this->Ksm_model->get_events();
$this->load->view('templates/template', $data);
}
and here is my Model:
public function get_events(){
$query = $this->db->get('events',1, 1);
return $query->result_array();
}
}
and finally the part in my view i want the message to display in:
<div class="panel-body" id="attractions">
<?php foreach ($events as $event_item): ?>
<?php echo "<p style='font-weight: bold; color: #555555;'>".$event_item['eventName']."</p>"; ?>
<?php echo "<p>".$event_item['eventInfo']."</p>"; ?>
<?php echo "<p style='color: #555555; font-weight: bold;'>"."Event Date: ".$event_item['eventDate']."</p>"; ?>
<?php endforeach; ?>
</div>
Please advise me on how to solve this problem?
thanks in advance
Riaan