Skip to content
Advertisement

How to show the Id number in descending order?

I am using PHP and I have to export the data from the database. I am using the below code which is working.

JavaScript

I am getting all the records.

enter image description here

Notice that I am getting all the records in descending order and id is showing ascending `order.

This is my expected output:

enter image description here

How can I show the Id in descending order?

Advertisement

Answer

You can do this way easily with the help of count() and decrementing the $len by 1

JavaScript

Note: You could do that id order descending on your select query side but as you are already using order by data_of_added DESC so I guess above snippet will do the trick for you.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement