Welcome Guest, Not a member yet? Register   Sign In
blog lesson
#9

[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">
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
    &lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body &gt;
  <h1>&lt;?=$heading?&gt;</h1>
  
  &lt;?php foreach($query->result() as $row): ?&gt;
    <h3>&lt;?=$row->title?&gt;</h3>
    <p>&lt;?=$row->body?&gt;</p>
    
    <p>&lt;?=$anchor("blog/comments/".$row->id, "Comments");?&gt;</p>
    
    <hr />

  &lt;?php endforeach; ?&gt;
  &lt;/body&gt;
&lt;/html&gt;

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.


Messages In This Thread
blog lesson - by El Forum - 11-13-2007, 04:34 AM
blog lesson - by El Forum - 11-13-2007, 07:39 PM
blog lesson - by El Forum - 11-14-2007, 12:49 AM
blog lesson - by El Forum - 11-14-2007, 08:18 AM
blog lesson - by El Forum - 01-12-2008, 03:48 AM
blog lesson - by El Forum - 01-12-2008, 04:59 AM
blog lesson - by El Forum - 01-12-2008, 07:08 AM
blog lesson - by El Forum - 01-12-2008, 07:22 AM
blog lesson - by El Forum - 01-12-2008, 02:03 PM
blog lesson - by El Forum - 01-12-2008, 02:17 PM
blog lesson - by El Forum - 01-12-2008, 03:09 PM
blog lesson - by El Forum - 01-12-2008, 03:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB