[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>';
}
}
}
}
?>
here is doesn't working MVC architecture of that script
Code:
//controller
<?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);
}
}
?>
my model
Code:
<?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;
}
}
}
?>
my view
Code:
<html>
<head>
<title>My Blog Page</title>
</head>
<body>
<h3>My Blogs</h3>
<div>
<p>
<ul>
<?php foreach($items as $row):?>
<h4><?=$row['text']?></h4>
<p><?=$row['date']?></p>
<p>Posted by <?=$row['name']?></p>
<?php endforeach;?>
</ul>
</p>
</div>
</body>
</html>