the problem is it print out the friends names as a numbers on this line of code
//
echo "<a href='profile?id=". $row['friend'] ."'>".$row['friend']."</a>";
What I have tried:
this is my full code which i have tried
$stmt = $conn->prepare("SELECT `friends`.*, users.username AS username FROM `friends` INNER JOIN `users` ON users.user_id = friends.user_id WHERE friends.friend = '".$_SESSION['user_id']."'
OR friends.user_id = '".$_SESSION['user_id']."'");
$stmt->execute();
$data = $stmt->fetchAll();
foreach ($data as $row) {
if ($row['friend'] == $_SESSION['user_id']) {
echo "<a href='profile?id=". $row['user_id'] ."'>".$row['username']."</a>";
}elseif ($row['user_id'] == $_SESSION['user_id']) {
echo "<a href='profile?id=". $row['friend'] ."'>".$row['friend']."</a>";
}
}