I’m trying to order a certain ID from highest to lowest.
Say, I have 5 id’s.
1
2
3
4
5
I’m trying to have it order my most recent/highest ID.
Like,
5
4
3
2
1
Here is the code that “posts” it (it’s for a blog, btw)
$post = mysql_query("SELECT * FROM blog ORDER BY id") or die(mysql_error());
I’m sure there is a way, but can’t understand how to very well.
You should have a look at
arsort()and related functions from the PHP Manual: http://www.php.net/manual/en/function.arsort.phpThis answer is assuming that you have put your values into an array:
$foo[] = { 1, 3, 4, 2, 5 };However, it is the general sentiment of the people watching this that you have not given enough information about your situation to properly answer the question. I can understand that viewpoint. Generally, you should include a slice of source code that concerns your specific question. Without that, you will probably be downvoted instead of given a proper answer. This is also a good way to show us that you are not simply having StackOverflow do your homework for you. 🙂In MySQL, your statement should include the
DESCkeyword for “descending”: