Welcome Guest, Not a member yet? Register   Sign In
my very simple guesbook doesn't work
#1

[eluser]linderox[/eluser]
I have very strange situation.I have 2 very similar simple scripts, which connect to the database and get data. But one of these doesn't works successfuly, but another doesn't give me anything even errors.
here is working script. Just only Conroller
Code:
<?php

class Testdb extends Controller {

    function Testdb()
    {
        parent::controller();    
    }
    
    function index()
    {    
        //$query = $this->db->query("SELECT name,text,date FROM guestbook")
        $this->db->select();
        $query = $this->db->get('guestbook');
        if ($query->num_rows() > 0)
        {
        foreach ($query->result() as $row)
            {
                echo $row->name;
                echo $row->text;
                echo $row->date;
                echo '<br>';
            }
        }    
    }
    
}
?&gt;

here is doesn't working MVC architecture of that script
Code:
//controller

&lt;?php

class Feedback    extends Controller {

    function Feedback()
    {
        parent::Controller();    
    }
    
    function index()
    {    
        $data['title'] = "guestbook";
        $this->load->database();
        $this->load->model('guestbook');        
        $this->load->helper('form');
        $data['items']=$this->guestbook->getdata();
        $this->load->view('feedback/index', $data);
        
    }
    
}
?&gt;
my model
Code:
&lt;?php

class Guestbook extends Model {

    function Guestbook()
    {
        parent::Model();    
    }
    
    
    function getdata()
        {
            $this->db->select('*')->from('guestbook');
            $query = $this->db->get();
            if ($query->num_rows() > 0)
                {
                    return $query->result_array();
                }
            else
                {
                    return FALSE;
                }
        }
    
}
?&gt;
my view
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Blog Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<h3>My Blogs</h3>  
<div>
<p>
<ul>
&lt;?php foreach($items as $row):?&gt;

<h4>&lt;?=$row['text']?&gt;</h4>
<p>&lt;?=$row['date']?&gt;</p>
<p>Posted by &lt;?=$row['name']?&gt;</p>

&lt;?php endforeach;?&gt;
</ul>

</p>
</div>
&lt;/body&gt;
&lt;/html&gt;


Messages In This Thread
my very simple guesbook doesn't work - by El Forum - 03-20-2009, 12:13 AM
my very simple guesbook doesn't work - by El Forum - 03-20-2009, 01:00 AM
my very simple guesbook doesn't work - by El Forum - 03-20-2009, 01:28 AM
my very simple guesbook doesn't work - by El Forum - 03-20-2009, 02:13 AM
my very simple guesbook doesn't work - by El Forum - 03-20-2009, 02:22 AM
my very simple guesbook doesn't work - by El Forum - 03-20-2009, 05:09 AM
my very simple guesbook doesn't work - by El Forum - 03-20-2009, 06:03 AM
my very simple guesbook doesn't work - by El Forum - 03-20-2009, 06:59 AM
my very simple guesbook doesn't work - by El Forum - 03-20-2009, 07:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB