I have some code that will delete a post from the database:
mysql_query("DELETE FROM `posts` WHERE ID = '$id'");
Now I want to set the auto increment minus one to keep up with the deleted post. Is this possible? If so, how can I do it? Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You really don’t want to do this.
Imagine the following happens:
A new post is made with id 100
A new post is made with id 101
A new post is made with id 102
Post 100 is deleted… your post counter is now at 101
A new post is made with id 101
So now you have two ids with 101? If your constraints let you, that’s bad. If they don’t let you, it’s impossible.
Either way, it’s best to just let the ‘id 101’ die forever. It won’t be missed, there’s a few billion more numbers to pick from…