Hello, I've got a news system on my website which uses a database. When a news post is made, a file is created and the filename is being stored in the database. Then on the page where I want my news to be I include all news files by using all the date in the database. The problem is, the oldest post is now on top and I want the newest to be there. So the data must be read in reverse order out of the database or all data must be stored somewhere temporary and being included in reverse order. //database connection file include_once('plugins/admin/users/dbConfig.php'); //get all data out of database $r = mysql_query("SELECT * FROM News"); //include all files while($row = mysql_fetch_array($r)){ include_once("plugins/news/data/" . $row['id'] . ".txt"); } Code (markup): Tia
Modify your query statement as: SELECT * FROM News order by <fieldname> desc; Of course, change the <fieldname> to whatever field you are sorting by without the brackets.
Try this: //database connection file include_once('plugins/admin/users/dbConfig.php'); //get all data out of database $r = mysql_query("SELECT * FROM News order by id desc"); //include all files while($row = mysql_fetch_array($r)){ include_once("plugins/news/data/" . $row['id'] . ".txt"); }