This question already has an answer here:
- Select last N rows from MySQL 4 answers
How can I fetch the list on my table in reverse order?
Like for example:
The records are
1 2 3 4 5
I want it in reverse
5 4 3 2 1
$query = "SELECT * FROM chat ORDER BY id DESC LIMIT 10";
$run = $con->query($query);
while($row = $run->fetch_array()):
?>
<div id="chat_data">
<table id="chattbl">
<tr>
<td>
<h3><?php echo $row['name']; ?>:</h3>
</td>
<td>
<p><?php echo $row['msg']; ?></p>
</td>
</tr>
</table>
<h5><?php echo formatDate($row['date']); ?></h5>
</div>
</div>