<?php 
include("postget.php");
include_once("common.php");
if (isset($_SESSION['ordenar'])) {
	checklevel(2,$_REQUEST['clientid']);
	
	//$_REQUEST['table-1'] = "table-1[]=0&table-1[]=3&table-1[]=2&table-1[]=1";
	$arreglo[] 	= $_REQUEST['table-1'];
	$arreglo = $arreglo[0];
	
	$arreglofirst = array_shift($arreglo);
	//$arreglofirst = array_keys($arreglo,0);
	
	if (!empty($arreglo)){
		// session vale "[tabla]{campo}(campo id)<where>"
		$param_tabla = strbet($_SESSION['ordenar'],'[',']');
		$param_campo = strbet($_SESSION['ordenar'],'{','}');
		$param_id = strbet($_SESSION['ordenar'],'(',')');
		$param_where = strbet($_SESSION['ordenar'],'<','>');
		
		$campoid = 1;
		foreach ($arreglo as $valor) {
			$query = "UPDATE $param_tabla SET $param_campo = ".$campoid." WHERE $param_id = ".$valor." $param_where";
			mysql_query($query) or die('Error, update query failed');
			$campoid ++;	
		}
	}
}
?>