hey guys, how to create profile like feature for lavalair script, plz share it
Profile like feature
Collapse
X
-
like feature
no no, i mean that how to code . plz share that codings. .hug. plzzz sirOriginally posted by something else View Post
Comment
-
yah, thats true dr, but i cant understand how to add that.Originally posted by nclemale36 View Postsimple. add a like field in your users table .
add mysql_query(update like in users where like=$who blah blah blah blah .lol .
onlong those lines. try and try again you will never learn if you dont try .
Comment
-
create some sql eg:
Then Create a mysql query to check if the user has liked the persons profile before followed by a simple if/else statement:PHP Code:CREATE TABLE `ibwf_profile_likes` (
`id` INT( 100 ) NOT NULL AUTO_INCREMENT ,
`uid` INT( 100 ) DEFAULT 0,
`likedby` INT( 100 ) DEFAULT 0,
PRIMARY KEY ( `id` )
);
Then you need to add a collection method of the like or dislike using $_GET and add or delete an database entry:PHP Code:$hasLiked = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_profile_likes WHERE uid='".$who."' AND likedby='".$uid."'"));
if($hasLiked[0]<1)
{
echo "<a href=\"profile.php?who=$who&sid=$sid&like=1\">Like</a><br/>";
}
else
{
echo "<a href=\"profile.php?who=$who&sid=$sid&like=0\">Dislike</a><br/>";
}
then last of all show total number of likes:PHP Code:if($_GET['like']==1)
{
mysql_query("INSERT INTO ibwf_profile_likes SET uid='".$who."', likedby='".$uid."'");
}
if($_GET['like']==0)
{
mysql_query("DELETE FROM ibwf_profile_likes WHERE uid='".$who."' AND likedby='".$uid."'");
}
This code is basic and could be made better but that's for you to work out, oh and also re-arranging the code on the page will make it work a lot better than copy and pasting it straight from her on to your profile page, and also i couldn't remember what the index.php?action=viewuser was called at the time of writing this so i just used profile.php and i cant be bothered to edit it lolPHP Code:$numOfLikes = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_profile_likes WHERE uid='".$who."'"));
echo $numOfLikes[0]." Likes<br/>";
Comment
Comment