Hi Guys
I am trying to display friends of a logged in user for my website, the user(person1 is friends with person2 and I would like this to display when either person1 or person2 log in( this should be under the hyperlink) Friends. and also to be able to see pending requests.
So far i have got this code but it gives me error messages. and does not work, any ideas please!!!!
<?php
session_start();
$user = $_SESSION["logged_user"];
// connection to the database
$query = mysql_query("SELECT * FROM users WHERE person2 = '$user' or person1 = $user");
$result=mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($query))
{
if ($user = $row["person1"] && $row["status"] == "1")
{
echo "$row[person2]";
}
else if ($user == $row["person2"] && $row["status"] == "1")
{
echo "$row[person1]";
}
else if ($user == $row["person1"] && $row["status"] == "0")
{
echo "$row[person2] - Awaiting to accept";
}
else if ($user == $row["person2"] && $row["status"] == "0")
{
echo "$row[person2] - Accept or reject";
}
}
mysql_close($conn);
?>
Any better ways that I could do this please i will really appreciate!!!!