I'm making a chat system like Facebook or Twitter.
Everything is okay but i don't know how to select last user's massage that the user has sent or received from them. I mean when you enter the message in Facebook you can see the last messages that you've seen or not seen.
There is img to explain more below.
I have a table named message having columns like below
(id,userTo,userFrom,message,date)
for example :-