<?php
include('../dao/auto_load.php');
$conecta = new \Conn\MySqlConnect();
$arr = filter_input(INPUT_POST, 'foo', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
$table = $conecta->real_escape_string(filter_input(INPUT_GET, 'table'));
if (is_array($arr) && !empty($arr))
    foreach ($arr as $key => $item)
        $conecta->query("UPDATE $table SET ordem = '" . ($key + 1) . "' WHERE id = '$item'") or die($conecta->error);