drax
Member
Registered: 5th Feb 05
Location: Sittingbourne, Kent
User status: Offline
|
After removing rows from a table, where an auto increment is placed on an ID field, is there anyway of having the auto increment continue from the last number, or to reorder them all?
So it doesnt leave it as
1
2
3
10
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Offline
|
There are ways of doing what you want but I personally wouldn't. That value is unique to the record, regardless of whether the record still exists. If you go renumbering stuff then you run the risk of duplicate key errors.
Could you not just increment the count in the application somewhere? ie. in PHP just throw a quick
$count++;
inside your loop and display that?
Alternatively if you want to renumber and are sure you'll never be deleting records again, export the table as CSV, open in Excel, blank the first column, save as CSV and re-import. The auto_increment field will take care of the blank field an increment as it should.
|
drax
Member
Registered: 5th Feb 05
Location: Sittingbourne, Kent
User status: Offline
|
Cheers Ian, i was just curious as to keep things tidy, but function over form.
working on abit of a heavy project at the moment, really trying to get back on foot with php only really touched basics with it about 6 years ago, so it is abit mind boggling at the moment..
|
|