I've looked around the site for similar problems with solutions and non seem to fix the problem I have. I have two tables; "friendlist" and "users". I'm trying to use the "FriendID" from "friendlist" to retrieve information from the "users" table. Everything works fine up until the while($row = mysqli_fetch_array($result)){}
loop then nothing else prints.
My code is as follows:
$query = "SELECT friendlist.FriendID, users.Name, users.Surname, users.Picture
FROM friendlist
INNER JOIN users
ON friendlist.FriendID = users.Id
WHERE friendlist.UserId ='".$id."'";
$result = mysqli_query($con, $query);
if(!$result){
echo "<br/><h4>You currently do not have any friends. Please click the Find Friends button to find a friend</h4>";
}else{
echo "<center><br/>Here is a list of all your friends:<br/>";
echo "<table>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>Pro Pic: <img style='width:200px; height:200px' alt='No Profile Picture' src='uploads/" .$row['Picture']. "' /></td>";
echo "<td>Name :" .$row['Name']. "</td>";
echo "<td>Surname :" .$row['Surname']. "</td>";
echo "<td><form method='post' action='viewFriend.php'>";
echo "<input type='hidden' name='friendId' value='".$row['FriendID']."'/>";
echo "<input type='submit' name='View' value='View Profile'/>";
echo "</form></td>";
echo "</tr>";
}
echo "</table></center>";
}
Nothing is displayed on the browser. Only the level 4 heading text: "Here is a list of all your friends" shows. But after that its empty space.
I've checked the sql query on mySql and it works perfectly fine. I have no idea what's wrong. Any help will be much appreciated. Thanks