Welcome Guest, Not a member yet? Register   Sign In
Comment system not working.
#4

(01-15-2018, 02:35 AM)neuron Wrote: Can you share you comments and posts table structure;

Also there are mistakes in your get comments query:
Instead of 
       $this->db->select('*');
        
$this->db->from('comments');
        
$this->db->where('comments', array('slug' => $slug));
        
$this->db->join('comments''comments.id = posts.id');
change to 
        $this->db->select('*');
        
$this->db->from('comments');

        $this->db->join('comments''comments.id = posts.id');
        
$this->db->where(array('slug' => $slug));

        $query = $this->db->get();

where clause comes after join;

and what is "posts.id" in your query?
        

This is my POSTS table in DB:
[Image: 1.png]

This is my COMMENTS table in database:
[Image: 2.png]

and this is my full code to "get" the comments for each post(Post_model).

PHP Code:
// Comments
 
   public function get_post_comments($slug){
 
       $this->db->select('username,email,website,body');
 
       $this->db->from('comments');
 
       $this->db->join('comments''comments.id = posts.id');
 
       $this->db->where(array('slug' => $slug));
 
       $query $this->db->get();
 
       
        if
($query->num_rows() >= 1){
 
           return $query->result();
 
       } else {
 
           return false;
 
       }
 
   
I do Front-End development most of the time 
Reply


Messages In This Thread
Comment system not working. - by kirasiris - 01-14-2018, 11:56 PM
RE: Comment system not working. - by neuron - 01-15-2018, 02:35 AM
RE: Comment system not working. - by kirasiris - 01-15-2018, 01:19 PM
RE: Comment system not working. - by neuron - 01-16-2018, 12:43 AM
RE: Comment system not working. - by kirasiris - 01-18-2018, 06:34 PM
RE: Comment system not working. - by InsiteFX - 01-15-2018, 05:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB