[eluser]Phil Sturgeon[/eluser]
Do it with MySQL commands in PHP. Set them all as unique keys and before you enter any new entry get the last number, increase it and put it back in.
It MIIIIGHT return an error if somebody else inserts the same command in the same fraction of a milisecond, but you can just put it in a loop that tries 3 or 4 times before failing. Problem solved!