You must not do this.
Do not accept an automatically incrementing unique identifier as a sequence number.
The word "unique" means that the identifier must depend on its string forever .
There is no connection between these numbers and the listing.
Imagine you want to select entries in alphabetical order. Where will your precious numbers be? The database doesn't look like an ordered list, as you probably think. This is not a flat file with lines stored in a predefined order. He has a completely different ideology. The rows in the database have no order. And it will be ordered only at a certain time, if it is explicitly set in ORDER BY .
It is also assumed that the database will search for you. Thus, you can say that with filtered rows or another order, this auto-increment number will have absolutely nothing to do with the actual positions of the rows.
If you want to list the result, this is the job of the presentation level. Just add a counter on the PHP side.
And again: these numbers should identify a specific record. If you change this number, you will never find your entry again.
Take this site for example. Stackup identifies its questions with this number:
stackoverflow.com/questions/ 3132439 / mysql-auto-decrement value
So, imagine that you saved this page address in a bookmark. Now Jeff comes and reviews the entire database. You click your bookmark and land on another question. The whole site will become a terrible mess.
Remember: numbering unique identifiers of evil!
source share