dimanche 3 mars 2019

Display records from sql database order by date newest first PHP

Thanks for looking. I'm trying to have posts on my website appear on the homepage as newest at the top.

As the posts are uploaded they go to the back of the list e.g. A new post would go to page 3 rather than the top of the homepage.

The code I have so far is:

$query = "SELECT u.username,p.* FROM posts  as p, users as u where p.user_id=u.user_id LIMIT $page_1, $per_page";

What would be necessary in order to have the newest posts shown at the top of the list rather than the end?

If you have any questions please don't hesitate to ask

The code is written in PHP




Aucun commentaire:

Enregistrer un commentaire