M
M
MartStap2014-06-01 23:03:44
PHP
MartStap, 2014-06-01 23:03:44

How to sort user's dialogs and create correct list?

There is a table
id - numbering
ot - sender
po - recipient
tex - message text
rand - unique number of dialogs
time - sending time
The problem is that I want to sort and display those to whom you sent messages. Like dialogues in social networks, so that the one you sent the last message to was at the top. Through order by id, desc is obtained in the test on the phpmyadmin itself, but it is not sorted on the site itself, please help.
19ad59735ddf472d84c7ef8e301642af.PNG

<?php
$query = mysql_query("SELECT DISTINCT `po` from `stena` WHERE `ot` = '".$userdata['users_id']."'
GROUP BY id DESC ");	
while($row = mysql_fetch_array($query)) {
$queryy = mysql_query("SELECT * from users ");	
while($roww = mysql_fetch_array($queryy)) {
echo '<tr><td>';
if ($row['po'] == $roww['users_id']) {
echo $roww['users_login'];
}
echo '</td></tr>';
}
}
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2014-06-01
@Sumor

For sorting in a sql query, the order by construct is used.
At the same time, read about sql injections.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question