Use the ORDER BY
clause in your query for this, like this:
SELECT id FROM table ORDER BY date DESC
Where:
-
id
= given to be returned;
-
table
= table to be queried;
-
data
= record date in the database;
-
DESC
= return decreasingly, from highest to lowest - using the logic of days: bring 30 before 29, just what you want.
Based on the edition of your post, do the following:
$sql = mysql_query("SELECT * FROM frame_anuncio WHERE ativo = 'Sim' ORDER BY destaque ASC, data DESC LIMIT $inicio, $maximo")or die(mysql_error());