Help - Search - Members - Calendar
Full Version: [resolved] Change/Reset ID Count?
Codegrrl.com Forums > Script Help > Tutorial Help
Sairah
My blog is working perfectly and is better than I could have hoped- thanks a bajillion times for that. I just have a small qualm...

In the beginning, I had about a thousand different posts to tests the various parts of my blog. Now that it's fully coded, I deleted them all to start "fresh". However, the only post I have right now is given the id number "9"...and I can't find any way of changing that or editing #1 [invalid ID specified], since it's been deleted.

Is there any possible way to restart the ID count? Maybe altering the sql table? O.o

Any help would be greatly appreciated for this!
Amelie
There is a way, but it involves resetting your MySQL table (which means you will lose everything in it).

If you have phpMyAdmin, go to the SQL tab of your database and type in:

SQL
TRUNCATE TABLE php_blog;


(Replace php_blog with the name of your posts table)

There is no way to do this in the blog script itself, however. If you have 100 entries and delete number 100, the next one will be 101 (so your entries will go from 98, 99, 101, etc) - you can't get ID 100 back. This is because the ID field is a unique number generated by MySQL which is always set as one you haven't used before. You can try to reset the auto_increment value (what MySQL uses to decide what the next number in the sequence is) but I have found this doesn't work. I might delete ID 100 and I don't want my next entry to be 101, but if I reset the value to be 100, my next entry is indeed ID 100 but my entry after that is 102 and I seem to have lost the ID number 101.

In short, the first way is the best way to do it, I've found wink.gif
Sairah
Hey, thanks- awesome, let me try it. Since I have no posts in the table yet, I might as well truncate it, right? Here's to hoping I don't royally screw myself over! XD

[EDIT] Thanks! It worked like a charm! -glomps- ^__^
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.