Lodius2000 Posted November 24, 2008 Share Posted November 24, 2008 I have a table with an INT field called id, i have a script that can delete a row if needed, problem is i need to re-number all of my rows because if i delete id=3, i am left with 1,2,4,5... I think i could do it with a few array functions (but im coming up blank on which they are), also the only way i can think to do that would be to set up a foreach and do an update for all the rows but could it also be done in sql help thanks Quote Link to comment https://forums.phpfreaks.com/topic/133958-solved-how-do-i-re-number-my-rows-in-my-db/ Share on other sites More sharing options...
DeanWhitehouse Posted November 24, 2008 Share Posted November 24, 2008 I have a table with an INT field called id, i have a script that can delete a row if needed, problem is i need to re-number all of my rows because if i delete id=3, i am left with 1,2,4,5... And the problem with that is? It doesn't matter if you have a gap in the numbers as they are just used as unique identifiers. Quote Link to comment https://forums.phpfreaks.com/topic/133958-solved-how-do-i-re-number-my-rows-in-my-db/#findComment-697338 Share on other sites More sharing options...
Lodius2000 Posted November 24, 2008 Author Share Posted November 24, 2008 hrm, i guess other than for display purposes (i use the old '<tr class="' . $styles[$i % 2] .'">' trick to make the table easier to read) it doesnt Quote Link to comment https://forums.phpfreaks.com/topic/133958-solved-how-do-i-re-number-my-rows-in-my-db/#findComment-697355 Share on other sites More sharing options...
trq Posted November 24, 2008 Share Posted November 24, 2008 hrm, i guess other than for display purposes (i use the old '<tr class="' . $styles[$i % 2] .'">' trick to make the table easier to read) it doesnt Primary keys should not be relied upon for ordering or manipulating the way data is displayed for this exact reason. Quote Link to comment https://forums.phpfreaks.com/topic/133958-solved-how-do-i-re-number-my-rows-in-my-db/#findComment-697363 Share on other sites More sharing options...
Lodius2000 Posted November 24, 2008 Author Share Posted November 24, 2008 agreed, have since rectified the problem solved Quote Link to comment https://forums.phpfreaks.com/topic/133958-solved-how-do-i-re-number-my-rows-in-my-db/#findComment-697394 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.