1
I have two tables, one of utilizadores
where I keep the username
and the id
, and I have another chat
where I keep the fields sender
and the reciever
, which are the user id of the user who received and sent the message.
Now, how can I display that the user logged in with the id=6
have messages exchanged with id=11
and the id=17
.
User can have 10 messages exchanged with user id=11
and a message only exchanged with the id=17
. I just want two lines to appear saying that the user id=6
have messages exchanged, in this case with two users.
This way I receive all messages that the user logged in with id=6
has with other users
$sql ="SELECT * FROM chat WHERE reciever = $id
UNION
SELECT * FROM chat WHERE sender = $id";
If the user is id=6
i receive 10 messages that this user exchanged with the user id=11
and a message he exchanged with the user id=17
Give an example so we can help.
– Andre Mesquita