[eluser]Unknown[/eluser]
Hi all,
I am new to CI and I have just stated to play around with it and I have to say its fantastic. However I have run into a problem that I just can't seem to get around.
I was watching the intro videos on this site and looked at how to create a blog, so managed to create a database and connect it to my app and I created a view and a controller.
Now the problem I have is I can't seem to output the data from the data base in to my view?
All I get in Firefox is:
$body
$body
$body
$body
$body
or
Code:
Severity: Notice
Message: Undefined variable: body
Filename: views/blogview.php
Line Number: 9
I am on Windows 7 and running WAMP with PHP version 4.4.9.
Here is the code that's in my controller (blog):
Code:
<?php
class Blog extends Controller{
function Blog(){
parent::Controller();
}
function index(){
$data['$title'] = "Hello and welcome to my blog";
$data['query'] = $this->db->get('entries');
$this->load->view('blogview', $data);
}
}
?>
And now the view (blogview):
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title><?php echo $title;?></title>
</head>
<body>
<?php foreach($query->result() as $row):?>
<p><?php echo $body;?></p>
<? endforeach; ?>
</body>
</html>
Can someone please tell me where I am going wrong? I have tried my best at looking at the code but I just can't see what I am missing...
Sorry for the silly n00b question but I guess we all have to start somewhere
Thanks in advance,
John