Imprimí la consulta y la usé en phpmyadmin y funcionó perfectamente.
Código PHP:
function updateGallery($matrix)
{
global $mysqli;
$query = "";
$i=0;
$count = count ($matrix);
while($i<$count)
{
$matrix[$i][0] = $mysqli->real_escape_string($matrix[$i][0]);
$matrix[$i][1] = $mysqli->real_escape_string($matrix[$i][1]);
$matrix[$i][2] = $mysqli->real_escape_string($matrix[$i][2]);
$query .= "UPDATE gallery SET category = '".$matrix[$i][1]."', position = ".$matrix[$i][2]." WHERE id = ".$matrix[$i][0]. "; ";
$i++;
}
$result = $mysqli->query($query);
return $mysqli->affected_rows;
}
Cita:
UPDATE gallery SET category = 'Not published', position = 0 WHERE id = 39; UPDATE gallery SET category = 'Not published', position = 1 WHERE id = 41; UPDATE gallery SET category = 'Not published', position = 2 WHERE id = 40; UPDATE gallery SET category = 'Not published', position = 3 WHERE id = 38; UPDATE gallery SET category = 'Not published', position = 4 WHERE id = 36;