I have a while loop that loops through an array of user and admin messages. Each message holds a timestamp value. When I use the sql query:
SELECT * FROM Messages
WHERE user_id=....
ORDER BY message_timestamp DESC
this of course displays the most recent messages first. But when I use the same sql query in the while loop in PHP to fetch the messages:
$select_message = ($con, "SELECT *
FROM Messages
WHERE user_id='....'
ORDER BY message_timestamp DESC");
while($fetch_message = mysqli_fetch_array($select_message))
they are displayed but in ASC order, even when I have 'ORDER BY DESC'... I also tried ORDER BY ASC to see what will happen, but no changes...
This is what I have inside of the while loop...
if($fetch_message['message_author'] == 'aut1') {
echo "aut1";
} elseif($fetch_message['message_author'] == 'aut2') {
echo "aut2";
}
}
phpMyAdmin Schema. Timestamp is of value type TIMESTAMP
SELECT `message_id`,`message_author`,`user_id`,`consumer_email`,`message_content`,`admin_id`,`message_timestamp` FROM Messages;
I have been looking through some user questions on here but seems to work for most people.. could you help?