Welcome Guest [Log In] [Register]
Add Reply
friends system addition maybe ?
Topic Started: Dec 8 2008, 12:42 PM (176 Views)
php-coder
Member Avatar

Enter this into the userinfo.php maybe to stop people adding them selves, and maybe take it further and edit it so that if you visit a profile and they are your friend it will show Remove from friends list ? Just an idea but below is the code i was thinking of for the main task..

Edit it to suit your needs dont forgot would be nice if someone could post back a edited Ver for the users that arn't php guru's :).

Quote:
 
<?php
//database connection needed
$query = "SELECT id, username FROM yourusertable";
$result = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_assoc($result)){
if($row['id'] != $_SESSION['logged_id']){
echo "<a href="friendrequest.php?user={$row['id']}">{$row['username']}</a>";
}
}
?>


Glad to pass on any more ideas i have :)

~Pc
Offline Profile Quote Post Goto Top
 
Admin
Administrator
thanks, was attempting this for a little while (few hours) and gave up. :)
Offline Profile Quote Post Goto Top
 
php-coder
Member Avatar

hehe its kool just here to help out :)


~Pc
Offline Profile Quote Post Goto Top
 
php-coder
Member Avatar

dont forget mate, if you mod it to suit the normal script poist a edited script back here for the none Guru's as mine is for a more advancded version of the login system that JP made :)

~PC
Offline Profile Quote Post Goto Top
 
php-coder
Member Avatar

Hey all,

Updated my previous code for none guru's

Code:
 

/* If logged in user viewing own account dont give link to add self as a friend instead show friends list link */
if(strcmp($session->username,$req_user) == 0){
echo "<br><a href=\"friendlist.php\">Friends List</a><br>";
}
/* If logged in user viewing own account show friends requests list link */
if(strcmp($session->username,$req_user) == 0){
echo "<br><a href=\"newfriends.php\">Friend requests</a><br>";
}
/* If logged in user viewing other accounts, give link to add as a friend */
if ((strcmp($session->username,$req_user) !== 0) and ($session->logged_in)) {
echo "<p class='maintext'><a href='friendrequest.php?user=$req_user_info[username]'>Add as Friend</a></p>";
}



Just put this snippet into your userinfo.php page were you would like to display the information, this works for me if it doesn't for you let me know and i'll help you to resolve the error/problems your having with it.

~Pc
Edited by php-coder, Dec 9 2008, 01:08 AM.
Offline Profile Quote Post Goto Top
 
Admin
Administrator
nj php
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Friends System · Next Topic »
Add Reply