<?php
session_start();
if (!isset($_SESSION['FirstName'])) {
	exit;
}
include ('includes/db1config.php');
include ('../includes/mysql_connect.php');
if(isset($_POST['menuId'])){
 $qry="UPDATE content SET menu_id = '".$_POST['menuId']."' WHERE pageId = '".$_POST['pageId']."'";
 mysql_query($qry);
 die('1');
}


$i = 0;
//clear all first
 $qry="UPDATE menuCategory SET orderNum = $i WHERE recordKey = $value";
  mysql_query($qry);
  $i++;
foreach ($_POST['cat'] as $value) {
    // Execute statement:
     $qry="UPDATE menuCategory SET orderNum = $i WHERE recordKey = $value";
	 //save qry to test log for troubleshooting
	 $query="insert into test_log (field1, field2) values ('update category_order','$qry') ";
	 mysql_query($query);
	 mysql_query($qry);
    $i++;
}

?>