Reputation: 6355
Hi I have a like button which updates the likes table field type with like. I want to count the number of likes in the table, in my controller I have this,
// Load Likes Model and retrive number of likes and dislikes
$this->loadModel('Like');
$related_likes = $this->Like->find('count', array(
'conditions' => array('uploadid' => $id)
));
$this->set('likes', $related_likes);
}
How do I go about echoing the number of likes in my view??
Would really appreciate any help
Upvotes: 0
Views: 170
Reputation: 7882
When you use set()
, the name you define becomes a variable in the view.
In your view:
echo $likes;
Upvotes: 3