[eluser]WavyDavy[/eluser]
This is the code I have:
blog.php
Code:
<?php
class Blog extends Controller {
function Blog()
{
parent::Controller();
$this->load->helper('url');
$this->load->helper('form');
}
function index()
{
$data['title'] = "My Blog Title";
$data['heading'] = "My Blog Heading";
$data['query'] = $this->db->get('entries');
$this->load->view('blog_view', $data);
}
function comments()
{
$data['title'] = "My Comment Title";
$data['heading'] = "My Comment Heading";
$data['query'] = $this->db->get('entries');
$this->load->view('comment', $data);
}
}
?>
and this is the code for blog-view.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?=$title?></title>
</head>
<body >
<h1><?=$heading?></h1>
<?php foreach($query->result() as $row): ?>
<h3><?=$row->title?></h3>
<p><?=$row->body?></p>
<p><?=$anchor("blog/comments/".$row->id, "Comments");?></p>
<hr />
<?php endforeach; ?>
</body>
</html>
The code is exactly the same as the tutorial, but in the tutorial he does this wierd thing where he doesnt put the comments table in until well after he has written this code, he even deliberately tests this code so he gets error 404 pages so he can show the path url in the browser.
Its like he is doing things back to front, shouldnt he have created the comments table before writing this code? I am going to try creating a comments table and see what this does.