Welcome Guest, Not a member yet? Register   Sign In
no Author Displayed
#1

[eluser]GamingFusion[/eluser]
Ok my comment insert Function is working and adding the data to the table but it's not displaying the author name when displaying the comments. What could be wrong. I ahve double checked and triple Checked my code and it's all right.

heres all the code thats included

feed.php(Controller)
Code:
<?php

class Feed extends Controller {
    
    function Feed()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->helper('form');
    }

    function index ()
    {
        $data['title'] = "GamingFusion | Feed";
        $data['heading'] = "The Feed";
        $data['query'] = $this->db->get('entries');
        
        $this->load->view('feed', $data);
    }
    
    function comments()
    {
        $data['title'] = "Comment Title";
        $data['heading'] = "Comment Heading";
        $this->db->where('entry_id', $this->uri->segment(3));
        $data['query'] = $this->db->get('comments');
        
        $this->load->view('comment', $data);
    }
    
    function comment_insert()
    {
        $this->db->insert('comments', $_POST);
        
        redirect('feed/comments/'.$_POST['entry_id']);
    }
    
}

?>

feed.php(View File)
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;
&lt;/head&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('feed/comments/'.$row->id, 'Comments' );?&gt;</p>
<hr />

&lt;?php endforeach; ?&gt;

&lt;/body&gt;
&lt;/html&gt;

comment.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;
&lt;/head&gt;
<h1>&lt;?=$heading?&gt;</h1>

&lt;?php if ($query->num_rows() > 0): ?&gt;

&lt;?php foreach ($query->result() as $row) : ?&gt;

<p>&lt;?=$row->body?&gt;</p>
<p>&lt;?=$row->author?&gt;</p>


<hr />

&lt;?php endforeach; ?&gt;
&lt;?php endif; ?&gt;

<p>&lt;?=anchor('feed', 'back to The Feed' );?&gt;</p>

&lt;?=form_open('feed/comment_insert');?&gt;

&lt;?=form_hidden('entry_id', $this->uri->segment(3));?&gt;

<p>&lt;textarea name="body" rows="10"&gt;&lt;/textarea></p>
<p>&lt;input type="text" name"author" /&gt;&lt;/p>
<p>&lt;input type="submit" value="Submit" /&gt;&lt;/p>
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
#2

[eluser]GamingFusion[/eluser]
i fixed it no need to reply




Theme © iAndrew 2016 - Forum software by © MyBB