[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">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$title?></title>
</head>
<h1><?=$heading?></h1>
<?php foreach ($query->result() as $row) : ?>
<h3><?=$row->title?></h3>
<p><?=$row->body?></p>
<p><?=anchor('feed/comments/'.$row->id, 'Comments' );?></p>
<hr />
<?php endforeach; ?>
</body>
</html>
comment.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$title?></title>
</head>
<h1><?=$heading?></h1>
<?php if ($query->num_rows() > 0): ?>
<?php foreach ($query->result() as $row) : ?>
<p><?=$row->body?></p>
<p><?=$row->author?></p>
<hr />
<?php endforeach; ?>
<?php endif; ?>
<p><?=anchor('feed', 'back to The Feed' );?></p>
<?=form_open('feed/comment_insert');?>
<?=form_hidden('entry_id', $this->uri->segment(3));?>
<p><textarea name="body" rows="10"></textarea></p>
<p><input type="text" name"author" /></p>
<p><input type="submit" value="Submit" /></p>
</form>
</body>
</html>