Welcome Guest, Not a member yet? Register   Sign In
help with query
#3

[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>&lt;?php echo $heading; ?&gt;</h1>

<hr>

&lt;?php if($query->num_rows() > 0): ?&gt;

&lt;?php foreach($query->result() as $row): ?&gt;

    <h3>&lt;?php echo stripslashes($row->title); ?&gt;</h3>
    &lt;?php echo date('l M j, Y    g:i a',strtotime($row->start)); ?&gt;
    <p>&lt;?php
        echo stripslashes($row->description);
        echo "<h4>By ".$row->createdby."</h4>";
        ?&gt;</p>

    <hr>
    &lt;?php endforeach; ?&gt;
&lt;?php endif; ?&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;


Messages In This Thread
help with query - by El Forum - 01-08-2010, 03:46 PM
help with query - by El Forum - 01-08-2010, 03:50 PM
help with query - by El Forum - 01-08-2010, 03:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB