[eluser]dadamssg[/eluser]
sweet well thats working now...maybe you can help me with putting it all work. I'm tryin to use a model that i just created. its not allowing me to use num_rows() on $query. It doesn't recognize it as an object. I don't know what im doing wrong
heres my controller
Code:
<?php
class Mains extends Controller {
function Mains()
{
parent::Controller();
$this->load->helper('url');
$this->load->helper('form');
}
function index()
{
$data['title'] = "Home";
$data['heading'] = "All Events";
$this->load->model('Frontmodel');
$this->Frontmodel->get_all_events();
$this->load->view('main_view', $data);
}
}
?>
heres my model
Code:
<?php
class Frontmodel extends Model {
function Frontmodel()
{
parent::Model();
}
function get_all_events()
{
$data['query'] = $this->db->query("SELECT * FROM test WHERE end >= NOW() AND event != 'Surrounding' ORDER BY start ASC");
return $data['query'];
}
}
?>
and my view
Code:
<?php
session_start();
include("header_view.php");
head();
?>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<h1><?php echo $heading; ?></h1>
<hr>
<?php if($query->num_rows() > 0): ?>
<?php foreach($query->result() as $row): ?>
<h3><?php echo stripslashes($row->title); ?></h3>
<?php echo date('l M j, Y g:i a',strtotime($row->start)); ?>
<p><?php
echo stripslashes($row->description);
echo "<h4>By ".$row->createdby."</h4>";
?></p>
<hr>
<?php endforeach; ?>
<?php endif; ?>
</form>
</body>
</html>