<?php
$nSecureMe=1;

// Secure and connect
require("../../inc/dbconnect.php");
require("../inc/secure_page.php");

// Accessed by AJAX froma page ordering script
// Recieves the following via POST:
// group - contains the section name (e.g. section_9)
// order - a list of items in the order chosen by user (e.g. icon_23,icon_24)

$nGroup = $_POST["group"];
$nOrderData = $_POST["order"];

$nGroup = str_replace("section_","",$nGroup);
$nOrderDataARRAY = explode(",",$nOrderData);

if($nGroup!==""){
	$nOrderNum = 1;
	// next, update the items in one by one
	foreach($nOrderDataARRAY AS $nItemID){
		$nItemID = str_replace("icon_","",$nItemID);
		if($nItemID){
			$nSQL = "UPDATE nPage SET nSectionID='$nGroup',nOrderID='$nOrderNum' WHERE nID=$nItemID LIMIT 1";
			// echo "nSQL: $nSQL";
			mysql_select_db($DBName);
			mysql_query($nSQL, $Link);
		}
		$nOrderNum++;
	}
}
?>
<?php require("../inc/db_close.php"); ?>