When i delete a record from my MySQL database it works fine, but then when i reload the form to Insert another record, it sticks the record into the database but at the position where i deleted the record.
Can someone show me a way of keeping the autoincrement at the last record in the database even after i delete a record?
Thanx
Problem with Auto-Increment and Deleting
Moderator: General Moderators
- Johnm
- Forum Contributor
- Posts: 344
- Joined: Mon May 13, 2002 12:05 pm
- Location: Michigan, USA
- Contact:
Get the highest record number from the database.
Something like:
save it as a variable and increment it,
Then submit it as a new record to the database with the rest of the data you need to store.
Direwolf
Something like:
Code: Select all
select MAX(record_number) from database_table...Code: Select all
$max_record=$rowї'(max)'] + 1;Then submit it as a new record to the database with the rest of the data you need to store.
Direwolf
What if 2(or more) people do this at exactly the same time?Johnm wrote:Get the highest record number from the database.
Something like:save it as a variable and increment it,Code: Select all
select MAX(record_number) from database_table...
Code: Select all
$max_record=$rowї'(max)'] + 1;
Then submit it as a new record to the database with the rest of the data you need to store.
Direwolf