Hello,
Created a query for getting users list excluding the logged in user well I thought about creating a simple one but huh that didn't worked for me. Okay so what logic and for what did I created for. I tried to show the users that are friends with each other so in messeging box obviously to send a message users will only see thier friends with the elimination of logged in user name
Let suppose
user 1 is friend of user 2
user 1 is friend of user 3
So in the messages page I want to show the list of users i mean friends like this
user 2
user 3
Make sense? so this was the scenario I was looking to create but what happens here by using my logic when user 1 is logged in it show the messages tab like this
user 2
user 3
This is okay working fine but when I logged in as user 2 to send a reply to user 1 what happens in the list user 2 is not showing up how ??
Here is my sql table for messages
Messages table
msg_id | user_1 | user_2 | message | time
------------------------------------------
1 | user 1 | user 3 | Hello | timestamp
2 | user 1 | user 2 | Hello | timestamp
3 | user 1 | user 3 | Hello | timestamp
4 | user 1 | user 3 | Hi | timestamp
Friends Table
userid | user_1 | user_2 | status
--------------------------------
1 | user 1 | user 2 | 1
2 | user 1 | user 3 | 0
Sor retreiving the users list I created the sql query as
<?php
$get = mysqli_query($connection, 'SELECT * FROM friends INNER JOIN users ON friends.user_1 = users.uid WHERE status = "1" AND uid != "'.$_SESSION["uid"].'"');
while($user = mysqli_fetch_assoc($get)) {
if($user["user_1"] == $_SESSION["uid"]) {
$pid = $user["user_1"];
} elseif ($user["user_2"] == $_SESSION["uid"]) {
$pid = $user["user_2"];
}
echo "<li><a href='#".$pid."'";
?>
onclick='ajax_post(<?=$pid?>)'
<?php echo "data-toggle='tab'>".$user["username"]."</a></li>";
}
?>
When user 1 is logged in I can see the users list but when user 2 is logged in the users list is not showing up can anyone help me out with this. I am sorry I am not good in explanations so I cannot explain in so much brief