Hi fellow programmers!
What I want to do is this...
* I have a list of registered users
* next to each user is a link "Add as friend"
* user_1 clicks the link to add user_2
* user_2 now needs to confirm or deny the request
WILL THIS TABLE WORK?
+-------------------------------------+
| friends |
+----+-----------+-----------+--------+
| id | user_id | friend_id | status |
+----+-----------+-----------+--------+
| | | | |
| | | | |
| | | | |
| | | | |
+----+-----------+-----------+--------+
And lets say I have add_friends.php. HOW WILL THE QUERY look in the php file?
what I have so far is this:
<?php
//create_cat.php
include 'connect.php';
include 'header.php';
if(isset($_SESSION['signed_in']) == false || isset($_SESSION['user_level']) != 1 )
{
//the user is not an admin
echo '<br/>';
echo 'Sorry! You have to be <a href="/signin.php"><b>logged in</b></a> to view all the <a href="signup.php" title="Become a registered user!"><b>registered</b></a> members.';
echo '<br/><br/>';
}
else
{
echo '<h2>Registered users:</h2>';
$sql = "SELECT `user_name` FROM `users` ORDER BY `user_name` ASC";
$result = mysql_query($sql);
while($user = mysql_fetch_array($result))
echo $user['user_name'].'
<a href="#"> ADD TO FRIENDS </a><br/><br/>';
///////////////////////////////
/// adding users as friends ///
///////////////////////////////
//HOW WILL THE CODE/QUERY LOOK IF I WANT TO ADD THE USER AS A FRIEND?
}
include 'footer.php';
?>
I'm struggling a long time now with this... YOUR HELP WILL BE SO MUCH APPRECIATED!!!