Hi Guys,
I am new to the forum and codeiginter i would like some help in solving a little problem…I have an events table that pulls one record out the database and displays it a view…what i am trying to achieve is that if there are no posts how do i output the message “Sorry there are no events scheduled”???
<?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);
}[/code]
My Model
---------------------
[code]<?php
class Ksm_model extends CI_Model{
public function __construct(){
{
$this->load->database();
}
}
public function get_events(){
$query = $this->db->get('events',1, 1);
return $query->result_array();
}
}
}
<div class="panel-body" id="attractions">
<?php foreach ($events as $event_item): ?>
<?php echo "".$event_item['eventName'].""; ?>
<?php echo "".$event_item['eventInfo'].""; ?>
<?php echo ""."Event Date: ".$event_item['eventDate'].""; ?>
<?php endforeach; ?>
</div>
Please could you explain to me how to achieve this….
thank you in advance
Riaan V
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.