I have very basic php question. I am fetching data from database and printing them with some styling row by row. The problem is that these data represent news and I would like them to be printed in reverse order (the last row I fetch should be printed first). I am not sure if I can fetch the whole table at once and them apply the reverse function (I tried it but it didnt work).
Here is my code:
<?php
include 'dbconnect.php';
$data = mysql_query("SELECT * FROM news") or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
echo '<article><h3> '.$info['subject'].'</h3><div id="date">'.$info['date']. '</div>';
echo '<p>'.$info['news']. '</p></article>';
}
?>
I tried something like this:
$data = [];
array_push($array, $info);
inside the while loop and then printing it but it didnt turn out to work. Thanks for any answer!
array_reverse? php.net/manual/en/function.array-reverse.php