$orderedSet = new OrderedSet(null); $query = "\n\t\tSELECT\n\t\t\tsection_id, section_order\n\t\tFROM\n\t\t\tsection\n\t\tWHERE\n\t\t\tFK_site = '" . addslashes($site_id) . "'\n\t\tORDER BY section_order\t\t\t\n\t"; printpre($query); $r = db_query($query); // Populate the Set with the original page order while ($a = db_fetch_assoc($r)) { printpre($a['section_order'] . "-" . $a['section_id']); $orderedSet->addItem($a['section_id']); } // Move our page to its new position $orderedSet->moveToPosition($_REQUEST['reorderSection'], $_REQUEST['newPosition']); // Save the new order $orderedSet->reset(); // Make sure the iterator is at the begining. $order = 0; while ($orderedSet->hasNext()) { $item = $orderedSet->next(); printpre($order . "-" . $item); // Update the db $query = "\n\t\t\tUPDATE\n\t\t\t\tsection\n\t\t\tSET\n\t\t\t\tsection_order = '" . addslashes($order) . "'\n\t\t\tWHERE\n\t\t\t\tsection_id = '" . addslashes($item) . "'\n\t\t"; //printpre($query); $r = db_query($query); $order++; } $showorder = "section"; } } } // exit; $returnURL = $_SERVER['PHP_SELF'] . "?&action=viewsite&site=" . $_REQUEST['site'] . "§ion=" . $_REQUEST['section'] . "&page=" . $_REQUEST['page'] . "&showorder={$showorder}" . ($_REQUEST['story_set'] ? "&story_set=" . $_REQUEST['story_set'] : ""); //printpre($returnURL);