socket.io messaging system where the users id in the messages table is in both the from_id and to_id column.
I want to get the last message between a user and each friend from the messages table whether its a sent or received message id.
messages table:
id from_id to_id message
1 20 30 xxx
2 30 20 xxx
3 20 71 xxx
4 20 40 xxx
5 20 71 xxx
6 40 20 xxx
7 71 20 xxx
8 18 20 xxx
9 20 18 xxx
10 18 20 xxx
my out put result must be like so:
Between 20 and 30 last id = 2
between 20 and 71 last id = 7
Between 20 and 40 last id = 6
Between 20 and 18 last id = 10
I have no code sample:
My goal is to get the last message between the users id and each friend and display the first few characters like it is in whatsapp when you view the chats page.
There is the friends image, friends name and a teaser of the last message between the two of you.