I wrote one yesterday...here is it...the concept is simple...works like a charm...
// we need to reorder things
if ($sec_ord > $hsec_ord) { // $hsec_ord is the old order number
// 999 is the number i use for things that are not in the sorted list
// hence the reason i exclude them from the action
$db->updateRecord("UPDATE ".PX."sections SET
sec_ord = sec_ord-1
WHERE sec_ord != '999'
AND (sec_ord > '$hsec_ord')
AND (sec_ord <= '$sec_ord')");
} elseif ($sec_ord < $hsec_ord) {
$db->updateRecord("UPDATE ".PX."sections SET
sec_ord = sec_ord+1
WHERE sec_ord != '999'
AND (sec_ord < '$hsec_ord')
AND (sec_ord >= '$sec_ord')");
} else {
// do nothing here
}
All in all, it's just a simple math problem. If I could do it, anybody can. 😉