Steve,
This should work as some basic sudo code. You are running into a number of
issues with your usage of the foreach as it sounds like what you really want to
do is walk through one array and grab the corresponding value from another.
<?php
// First check to make sure you are getting both fields
if(isset($_POST['name']) && is_array($_POST['name']) && isset($_POST['order'])
&& is_array($_POST['order']))
{
// Now assign them to easier to play with variables
$names=$_POST['name'];
$orders=$_POST['orders'];
// This tests for the same number of items as names
if (count($names) == count($orders))
{
$i=0;
while($i<=count($names))
{
$update_data = "UPDATE sections SET `order` = '$orders[$i]' WHERE name =
'$names[$i]'";
$response = mysql_query( $update_data, $cnx );
if(mysql_error()) die ('database error<br>'.mysql_error());
}
}
}
?>
HTH,
Wolf
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php