Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $cases = array();
- $referenceids = $_POST['ids']; // array(1, 2, 10, ...)
- $orderCounter = 0;
- foreach($referenceids as $rid)
- {
- $orderCounter++;
- $cases[] = 'WHEN '.$rid.' THEN '.$orderCounter; // WHEN 1 THEN 1...
- }
- $query = 'UPDATE `table` SET `column` = CASE `referenceid` '.implode("\n", $cases).' END WHERE `referenceid` IN('. implode(',', $referenceids).')';
- $result = mysql_query($query);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement