[eluser]Ahmed Iqbal[/eluser]
Hello Friend,
i need help in my query
Code:
function home_get_post() {
$this->db->from('post');
$this->db->join('users','post.user_id = users.user_id');
$this->db->join('categories','post.cat_id = categories.cat_id');
$this->db->where('post_visible', '1');
$this->db->order_by('post.post_added_date', 'desc');
$this->db->limit(10);
$query = $this->db->get();
if ($query->num_rows > 0) {
foreach ($query->result() as $row)
$data[] = $row;
}
return $data;
}
i've one more table as name of 'comments'. so i want to count comments on every post...!
comment table has foreign key 'post_id'.
Please, help in query i want, when for each loop show posts results comments number also display with it....!
thanks waiting for reply..