Jump to content

AUTO INCREMENT question...


davinci

Recommended Posts

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).
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

  • 2 weeks later...
[!--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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.