I get an error "Error: Query was empty" after completing the task instead of the echo result. I suspect that the FOREACH still attempt to execute the query even the last array is updated. Am I right?
If yes, how can I correct this?
<?php
$con = mysql_connect("localhost", "$username" , "$password");
mysql_select_db($database, $con);
?>
<?php
foreach ($_POST['id'] as $key=>$id)
{
$order = $_POST['order'][$key];
mysql_query("UPDATE table SET `order`=$order WHERE `id` = $id");
}
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "<div class=\"result\">**1 record updated**</div>";
?>
Many thanks
More information about the form posting these value : Create array from form and update mysql