PHP - Moved: Friend System
This topic has done the Monster Mash to MySQL Help.
http://www.phpfreaks.com/forums/index.php?topic=343718.0 Similar TutorialsHello All, I'm making a networking script for my cms to allow users to befriend each other, I've got adding each other as friends down, that is no longer an issue. My issue is displaying friends on a profile page. Say Matt added Frank, and frank accepted the request, well on Matts page it'll show frank as a friend, but on franks page it won't show Matt as a friend. My MySQL table has just 4 Rows id | user_id | friend_id | approved -id is a primary unique key -user_id is who sent the reuqest -friend_id is the id of the user the request was sent to -approved is the status, 0 for no accepted, 1 for accepted. On the user profile page, this is the sql query used to generate the friends list $friends = $db->get_table("SELECT * FROM zxt_friends WHERE user_id = '{$u['id']}' AND approved = '1'"); foreach ($friends AS $friend) { $friend['friend_name'] =$zext->user_cache[$friend['friend_id']]['username']; $avatar = $zext->user_cache[$friend['friend_id']]['avatar']; $friend_html = $friend['friend_name'].$avatar; } Before I tried using a different sql query, it looked like this: $friends = $db->get_table("SELECT * FROM zxt_friends WHERE user_id = '{$u['id']}' OR friend_id = '{$u['id']}' AND approved = '1'"); But the approved status was ignored, and it was all kinds of messed up, on my page it would show that Matt is indeed friends with frank, and a member that had not approved the reuqest yet, and on Frank's page it showed that he was a friend with himself when that wasn't even the case. I've looked at array_push but I can't seem to figure out the query or what I need to add the the loop, any help would be much appreciated. Thanks, Matt. I have made a mutual friend system like facebook and it shows all the mutual friends but sometimes it shows it twice because your 2 friends might be friends with one person so it echos the same person twice so i wanna only show the person once and the most repeated should show on the top and the less repeated person should show at bottom!
Need some help here! I want to build a friendgroup - I have a full working friendsystem. My ide is this. I got a list of friends, make a group named Test. Put selected friends in there, make another group and put another friends in there. Some idees how to do that with prepared statements?? I search for tutorials, but couldn't find any. Any suggestions? The functions I need is this: 1. Make group 2. Add friend to group 3. Show group with selected friends 4. Rename groups 5. Move friend from one group to another 6. Delete group with all friends inside 7. Delete a empty group 8. Option to search for friends inside a group Tutorial, free source code - everything would help to solve this mystery ! So far is this the code I made, and didn't work at all public function create_friendgroup($profileownerid, $friends = NULL, $name) { $sql = "SELECT fg_friends_id FROM friend_groups WHERE fg_member_id = '$profileownerid' LIMIT 1"; if($stmt = $this->conn->prepare($sql)) { $stmt->execute(); $stmt->bind_result($friend); $stmt->fetch(); $stmt->close(); } if($friend != null) { $ua = explode(",", $friend); $ua = array_unique($ua); foreach ($ua as $u) { if($u !=NULL && $u !=$profileownerid) { $oldusers .= "{$u},"; } } } $newusers = $profileownerid; if ($oldusers != null) { $newusers .= "," . $oldusers; } $sql = "INSERT INTO friend_groups(fg_member_id,fg_friends_id, fg_name, fg_created_date) VALUES (?,?,?,?)"; $date = date("d-m-Y H:i"); if($stmt = $this->conn->prepare($sql)) { $stmt->bind_param('iiss',$profileownerid,$friends = trim($newusers, ","), $name,$date); $stmt->execute(); $stmt->close(); } } K.F This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=314868.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=345826.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=319007.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=314181.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=352279.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348317.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348500.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=358615.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=346529.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=317096.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=313919.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=359002.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=349747.0 I have a simple tell a friend script that works fine for the moment. its a simple.... $email = $_POST['email']; { mail("$email","Request","Dear Member, \n\nbla bla bla bla bla\n\n\n\n"); } I have an issue now though. The form now needs to be able to send 5 separate emails to 5 different people. How would this be done or is this even possible with the code I have? $email1 = $_POST['email1']; $email2 = $_POST['email2']; Hi everyone, I built a php site which uses $_GET['id'] to create a page for every picture in a gallery. I added a Google Friend Connect(http://www.google.com/friendconnect) widget which is suppost to allow ratings and comments on every page but every page is treated as index.php page examples http://daroom.info/index.php?id=2053345520104164875S600x600Q85.jpg http://daroom.info/index.php?id=21.jpg Does anyone have any solutions to this problem? Hey everyone, I'm currently working on a friends online script and i have a slight problem that i need help with. Basically the code first searches "TBL_Friends" to see if you have any friends added. If it returns results it then turns your friends ID's into a variable. It then searches "TBL_Users_Online" to see if any body is logged based on the friend's ID it returned before. The first bit of the code works and it retrieves all the friends i got added. The second half is odd, if i have one or two friends added it will show that one is online. If i have more then three friends added it returns no results. I know my code is a bit sloppy and probably not the best way of writing it, im still learning PHP. Anyways this is the code, any help is appreciated. Code: [Select] <?php $FriendsOnline = mysql_query("SELECT Sender_ID FROM TBL_User_Friends WHERE Reciever_ID = $UserID"); while($fo=mysql_fetch_array($FriendsOnline)) { $FriendsOnlineID = $fo[Sender_ID]; $FriendsOnlineNumber = mysql_query("SELECT * FROM TBL_Users_Online WHERE User_ID = $FriendsOnlineID"); $FriendsNumber = mysql_num_rows($FriendsOnlineNumber); echo $FriendsNumber; } ?> $SenderID = Friends ID $Reciever_ID = User ID $UserID = User ID hello dear PHP-Fans - greetings to you - and a happy new year!! i set up a WAMP-System on my openSuse 11.4 system. In order to learn as much as i can bout PHP i want to do some tests and write some scripts. Well the WAMP is allready up and running. Now i try to give the writing access to the folder mkdir /srv/www/ where the php-scripts should go in... i want to give write permission to all to all files in /srv/www As root I generally: mkdir /srv/www/ chown <webmaster usrername> /srv/www/ /srv/www/ should be readable and traversable by all, but only writeable by it's owner (the user designated as the webmaster.) can i do this like mentioned above,... Love to hear from you greetings db1 |