[eluser]tonanbarbarian[/eluser]
You might want to consider a whole new take... or you might not
Anyway...
How about instead of having invoices IDS as a sequential number for each user what about a timestamp approach. Have the ID be the date time the invoice was issued. i.e. Y-m-d H:i
Invoice ID: 20071209232547
Invoice ID: 20071210105423
Not only does it allow you to see what order the invoices are issued, it allows you to immediately see when they are issued.
And if for whatever reason an invoice needs to be backdated it can be without having to give it a high invoice number.
Sorting will show the the invoices in the order they were created etc.
And of course no real code needed to generate the invoice id or process in any way, just insert the datetime or use a timestamp field.