1
I was wondering if it’s possible on a mysql_query
search and ORDER HER according to more recent updates from another table for example..
I have this query, when the user logs into the chat it gives a list of all registered users, but just shows what your friends are added.
$sqln = mysql_query("SELECT * FROM users WHERE (id = '$id') OR (id IN (SELECT user2_id FROM following WHERE user1_id='$id')) ORDER BY id ASC ");
But I would like to know if instead of searching in the users table, listing ASC
ordained by id
, search in another table chat
where he would find the person’s id, (id_de
), and would bring back the latest messages to get something more up-to-date, listing first the most recent conversations.. as in applications like WHATSAPP.
It seemed?
Make another table for the messages and associate the messages for each user so continuing to sort by id your users and within them their respective messages will be records of the linked messages table with the "users" can be ordered by date.
– Paulo Roberto Rosa
mysql_query is being discontinued, I suggest you use PDO.
– Ivan Ferrer