View Full Version : Facebook like system.

12-08-2010, 10:57 PM
Right for the last few day's i've been trying to figure out how to get my like system on wall post's on people's profile's.

$postsLikes2 = $db->query("SELECT * FROM posts_likes WHERE `post_id` = '".$posts['id']."'");
$postsLikes = $db->assoc($postsLikes2);
$postsLikesNum = $db->num($postsLikes2);
$likeCheckerQuery = $db->query("SELECT * FROM posts_likes WHERE `user_id` = '".$userIn['id']."' AND `post_id` = '".$posts['id']."'");
$likeCheckerNum = $db->num($likeCheckerQuery);
if($likeCheckerNum == 1) {
echo "<a href=\"".WWW."/#\" onClick=\"ajax.page('".WWW."/ajax/like.php?unlike=".$postsLikes['id']."'); return false\">Unlike (".$postsLikesNum.")</a>";
}elseif($likeCheckerNum == 0) {
echo "<a href=\"".WWW."/#\" onClick=\"ajax.page('".WWW."/ajax/like.php?like=".$posts['id']."'); return false\">Likes (".$postsLikesNum.")</a>";

Thats what i have at the moment & it works for the user that has liked it but when i log in with another user its not working how i want it to, meaning that when i i like with that other user so it has 2 likes its giving the lastest like id on all of the user's that log in so if user admin likes it and then user fred goes to unlike it , it unlikes admin's like to it and not fred's like to it.

Can anyone help!