Log in

View Full Version : Hey everyone, I gotta Question :)



hmsnacker123
04-17-2010, 03:10 PM
First of all, I haven't posted on here in a long while, some of the older Member's may know who I am. :)

Glad to see my Word Association Game is still going. :)

Ok, my question is:

I am currently writing a PHP + MySql guestbook, and i'm having a little trouble with deleting the posts, see, whenever I delete a post, it doesen't update the ID's so, say, i have 3 posts and i delete the 2nd post, it leaves post 1 & 3 and therefore looks wierd :S. I need to know how to update all the ID's so that it displays 1 & 2 for example.

;)

hmsnacker123
04-17-2010, 04:10 PM
Bumpity

james438
04-17-2010, 04:57 PM
Wouldn't it be better to leave the gaps and then whenever the next person signs the guest book you can put their name in the gap?

For example:


ID name
1 Fred
2 Rick
3 Sara

delete Rick. Table is now:


ID name
1 Fred

3 Sara

New person signs guest book. Table becomes:


ID name
1 Fred
2 John
3 Sara

I suppose if you still wanted to do it your way you could retrieve the contents of your table, put it into an array, resort the array to remove all of the gaps, drop all of the rows from the table, then populate your table with your sorted data.

hmsnacker123
04-18-2010, 04:18 PM
@james438

Thank's for the input, I'll try this, if it work's ill thank you. :)

Anyone else ?

james438
04-18-2010, 07:44 PM
If you get stuck, let us know and we can probably help you to create the script you need.