How to make so that the latest posts were at the top of the page, not the bottom?

hi, I can not understand how to make that the latest posts were at the top of the page, maybe in the html to fix something or in php, can you briefly describe it?
here is the code html:
<div class="art">
 <h1 class="title"> <?= $in['title']; ?> </h1>
 <h3> <?= mb_substr($in['tet'], 0, 100, 'UTF-8'). '...'. ;?> </h3> 
 <h4>article number: <?= $in['id']; ?> </h4>
</div>
June 27th 19 at 15:29
3 answers
June 27th 19 at 15:31
in the query to the database necessary to correct
June 27th 19 at 15:33
Short. An array of articles to sort. This can be done at the stage of the query to the database, and php. In theory, and at the front - but don't.
I mean to sort? - ike.Barro commented on June 27th 19 at 15:36
but, all understood, thanks - ike.Barro commented on June 27th 19 at 15:39
June 27th 19 at 15:35
It is necessary to sort the records by date from larger to smaller, adding to the query ORDER BY `column with the date of publication` DESC
For example:
SELECT * FROM `posts` ORDER BY `created_at` DESC
I did the same, but recent posts still appear down, can you tell me where is the error?
$re = mysqli_query($condb, "SELECT * FROM articles ORDER BY id DESC ");
 $in = mysqli_fetch_array($re);
- ike.Barro commented on June 27th 19 at 15:38
If you have, the larger the ID of the post, the newer the news, then it should work. - ike.Barro commented on June 27th 19 at 15:41

Find more questions by tags PHP