Profile like feature
Started on the old forum in September 2012 · view the original in the archive · old links redirect here
like feature
something else wrote: You can create a profile like feature using notepad++
here`s the share: Notepad++ Home
😉 lol
no no, i mean that how to code . plz share that codings. .hug. plzzz sir
simple. 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 .
nclemale36 wrote: simple. 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 .
yah, thats true dr, but i cant understand how to add that.
create some sql eg:
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 Create a mysql query to check if the user has liked the persons profile before followed by a simple if/else statement:
$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 you need to add a collection method of the like or dislike using $_GET and add or delete an database entry:
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."'");
}
then last of all show total number of likes:
$numOfLikes = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_profile_likes WHERE uid='".$who."'"));
echo $numOfLikes[0]." Likes<br/>";
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 lol