Hi everyone
I am trying to develop a friend system where you can view friends who you are friends with.
I have been able to get it to show one result but it wont show any other. Please can someone tell me what I am doing wrong.
Here is the code
<?php
require("check_session.php");
$id = $_SESSION['id'];
$username = $_SESSION['username'];
?>
Here is a list of your current friends.
<br />
<br />
<?php
$sql = mysql_query("SELECT * FROM friends WHERE user_id='$id' AND friend='1'");
while($fetch = mysql_fetch_assoc($sql))
{
$friend_id = $fetch['friend_id'];
}
?>
<?php
$usertable = mysql_query("SELECT * FROM users WHERE id='$friend_id'");
while($row = mysql_fetch_assoc($usertable))
{
$table_first = $row['firstname'];
$table_last = $row['lastname'];
echo $table_first; echo" "; echo $table_last; echo"<br /><br />";
}
?>
Thanks in advance