Profile like feature

Started on the old forum in September 2012 · view the original in the archive · old links redirect here

5 replies · 702 views · started 14 years ago · 1 min read

3 participants
rusith Newbie · 5 posts #1

hey guys, how to create profile like feature for lavalair script, plz share it

rusith Newbie · 5 posts #3

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

nclemale36 Lead · 537 posts #4

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 .

rusith Newbie · 5 posts #5

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.

something else Fellow · 2,296 posts #6

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

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close