PDA

View Full Version : update multiple records in MYSQL and PHP



BlackBeltNinja
August 22nd, 2006, 01:22 PM
I have several items in a table of my database.
they have numbers to identify their order, and the order system works great.

but if I delete one of these items that is in the middle of the order, then there is a gap in the order and gives me a few bugs.

basically I have this query that isnt totally functional


UPDATE list SET seq-- WHERE seq > '$delseq'

how would i pull off the seq--?
I just need to subtract one from all of the seq values past the one I just deleted.

skOOb
August 22nd, 2006, 01:55 PM
UPDATE list SET seq = seq - 1 WHERE seq > $delseq

BlackBeltNinja
August 22nd, 2006, 02:02 PM
works great! thanks a million skoob.

bwh2
August 22nd, 2006, 02:17 PM
you should be careful though for a few reasons:
1) if you have other tables that depend on that value, changing it will screw up the dependencies
2) if it's an auto_increment field, your auto increment value would not be repositioned by this operation