davinci Posted February 28, 2006 Share Posted February 28, 2006 Hi,Have a video post site and I use mySQL to display my videos through out my site. Whenever I upload a video it has an 'id' which is auto incremented. Each video is displayed with the following URL structure: ../video.php?id=1, ../video.php?id=2 and so on.I've deleted a whole bunch of videos and kept the few good ones. I renamed all my last 5 remaining 'id' entries so that they would be 1, 2, 3, 4, 5 instead of a bunch of gaps between numbers for the ones I've deleted. But now when I add an entry its being added as id 12 instead of 6 (as if I didn't delete entries). Is there a way around this? I just don't like having the gap in my site structure.In PHPmyAdmin I can see "Next Autoindex 12", is there a way to chaneg this value?Thanks![!--quoteo(post=350113:date=Feb 27 2006, 09:25 PM:name=davinci)--][div class=\'quotetop\']QUOTE(davinci @ Feb 27 2006, 09:25 PM) [snapback]350113[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi,Have a video post site and I use mySQL to display my videos through out my site. Whenever I upload a video it has an 'id' which is auto incremented. Each video is displayed with the following URL structure: ../video.php?id=1, ../video.php?id=2 and so on.I've deleted a whole bunch of videos and kept the few good ones. I renamed all my last 5 remaining 'id' entries so that they would be 1, 2, 3, 4, 5 instead of a bunch of gaps between numbers for the ones I've deleted. But now when I add an entry its being added as id 12 instead of 6 (as if I didn't delete entries). Is there a way around this? I just don't like having the gap in my site structure.In PHPmyAdmin I can see "Next Autoindex 12", is there a way to chaneg this value?Thanks![/quote]Found a feature in PHPmyAdmin table options to set the current auto increment value however when I enter a new one when it runs the query it doesn't actually change it sets the value for the original one (12). Quote Link to comment Share on other sites More sharing options...
fenway Posted February 28, 2006 Share Posted February 28, 2006 Why is everyone so hung up on these silly IDs? Who cares what the number is... (sigh)Anyway, you need to run a "ALTER TABLE AUTO_INCREMENT = 1" -- that will reset the counter. But as I've said many times before, it's unnecessary and unwise to rely on this number for anything at all except referential integrity. Quote Link to comment Share on other sites More sharing options...
wickning1 Posted February 28, 2006 Share Posted February 28, 2006 Fenway's right, just leave the data be. Start doing that when you have a real database, and you'll get in trouble fast. Quote Link to comment Share on other sites More sharing options...
dsaba Posted March 9, 2006 Share Posted March 9, 2006 [!--quoteo(post=350138:date=Feb 27 2006, 11:34 PM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Feb 27 2006, 11:34 PM) [snapback]350138[/snapback][/div][div class=\'quotemain\'][!--quotec--]Fenway's right, just leave the data be. Start doing that when you have a real database, and you'll get in trouble fast.[/quote]hey i have like the exact same problem! but you would reccomend somethign else instead of auto-increment ids? i have a relational database and with each tables id's is how i relate them to each other, therefore deeming it very important, you say that this isn't good?i'm curious to what practice or strategy you would advise then instead of this? all the php books i've read uphold these id numbers..lol Quote Link to comment Share on other sites More sharing options...
wickning1 Posted March 9, 2006 Share Posted March 9, 2006 No, auto increment is great, fabulous, fundamental, can't live without it. Just don't fiddle with the id once it's been assigned. Don't try to fix gaps or make the numbers "pretty". Quote Link to comment Share on other sites More sharing options...
fenway Posted March 9, 2006 Share Posted March 9, 2006 Exactly -- if you want to have pretty numbering on your page, do it in the output as your iterate over your result set; don't worry about the how the database internally handles it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.