Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renumber ID's

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I made a guestbook, now I want to make something that renumbers the guestbook ID when one or more are deleted so there aren't any "holes" (1, 3, 8, 10).

I have an idea how to do this, but have no idea how to make the code...

1. Read guestbook messages into an array (there are 12 records)
2. Drop table/ re-create table
3. Have another array sort out the posts and renumber the entries (1, 2, 3, 4 instead of 1, 3, 8, 10)
4. Insert new updated rows into table.

Is it possible to do that, and if so, could someone please help me with it?

Thanks! :)
 
yes it's possible to do that, but it's stupid.

All the entries should have distinct identities. Suppose you have GB=3, someone bookmarked it, you delete it, if you put another with the code 3, when the user retrieves the bookmark, it should fail instead of driving the user to another thing. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Nope, the thing is it's a guestbook and entries can't be bookmarked.
 
Bad Idea to try and renumber a database. if you are renumbering when an entry is made you'll end up with a huge gap or worse.

To display posts with a number, create the number using a while staement and as you display them, add your "fake" number. ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top