user0129e021939232
user0129e021939232

Reputation: 6355

cakephp echo count

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

Answers (1)

jeremyharris
jeremyharris

Reputation: 7882

When you use set(), the name you define becomes a variable in the view.

In your view:

echo $likes;

Upvotes: 3

Related Questions