Renumber row in sequential order using PDO
Posted: Thu Mar 24, 2011 9:06 pm
I have a table with an ID column which is the Primary key and auto incremented. I have another column named ORDER that contains a number. This number is used to define the order in which the row data is displayed on a page.
When I delete a row, the ORDER column will have a gap and I would like to renumber the subsequent rows to remove the gap. ie:
I want to renumber the rows:
ID ORDER
1 1
2 2
4 3
5 4
When I insert a new row I want the ORDER row to be given the NEXT sequential number
How do I do that using PHP PDO?
Thanks
When I delete a row, the ORDER column will have a gap and I would like to renumber the subsequent rows to remove the gap. ie:
I want to renumber the rows:
ID ORDER
1 1
2 2
4 3
5 4
When I insert a new row I want the ORDER row to be given the NEXT sequential number
How do I do that using PHP PDO?
Thanks