Welcome Guest, Not a member yet? Register   Sign In
Best Practice: Controller that handles multiple access methods (url/uri, ajax, post)
#5

[eluser]adityajoshi[/eluser]
i am having similar problem

<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<h1>Welcome to my blog</h1>
<ol>
<div = "posts">
&lt;?php foreach($query->result() as $row): ?&gt;
&lt;?php echo $row->title ?&gt;
&lt;?php echo $row->text ?&gt;
</div>
&lt;?php
$comment_display = $this->comment_display($row->id);
?&gt;
&lt;form method = "post" action = "http://localhost/feeders/index.php/blog/comment_insert"&gt;
&lt;?php echo form_hidden('entry_id',$this->uri->segment(3)); ?&gt;
<p>&lt;textarea name="text" rows="3"&gt;&lt;/textarea></p>
<p>&lt;input type="text" name="author" /&gt;&lt;/textarea></p>
<p>&lt;input type="submit" value="Submit" /&gt;&lt;/textarea></p>
&lt;/form&gt;
<hr />
&lt;?php endforeach; ?&gt;

</ol>
&lt;/body&gt;
&lt;/html&gt;



My controller is
&lt;?php
var_dump($_POST);
class Blog extends Controller {
function Blog()
{
parent::Controller();
$this->load->scaffolding('comments');
$this->load->helper('form');
$this->load->helper('url');
$this->load->model('blog_model');

}

function index()
{

$data['title'] = "Blog";
$data['list'] = array('first', 'second', 'third');
$data['query'] = $this->blog_model->get_blog_entries();
$this->load->view('blog_view',$data);
}

function comment_display($blog_id)
{
return $this->blog_model->show_comments($blog_id);
}

function comment_insert()
{
$this->db->insert('comments', $_POST);
redirect('blog');
}
}
?&gt;

my model is
&lt;?php
Class Blog_model extends Model
{
function get_blog_entries()
{
return $this->db->get('entries');
}
function show_comments($row_id)
{
$this->db->where('row_id',$row_id)->get('comments');
}
function insert_comment($data)
{
$this->db->insert('comments',$data);
}
}
?&gt;

i am getting the error

( ! ) Fatal error: Call to undefined method CI_Loader::comment_display() in C:\wamp\www\feeders\system\application\views\blog_view.php on line 21


can any one guide me


Messages In This Thread
Best Practice: Controller that handles multiple access methods (url/uri, ajax, post) - by El Forum - 07-06-2011, 09:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB