After finally resolving one problem, I ran into another that is so bugging me. This loop will not run the update query everytime through it, only at the end of the loop. Can anyone please tell me why?
Code: Select all
<?
if($_POST)
{
mysql_connect("$db_host", "$db_user", "$db_pass") or die ("DataBase connection error! Please try again later");
foreach (array_keys($_POST) as $key)
{
$$key = $_POST[$key];
$link_id = $key; ///<- printing this
$link_order = ${$key}; ///<- and this both work in every iteration
// This query won't update on every loop, just last iteration
$query="UPDATE menu SET link_order='$link_order' WHERE link_id='$link_id'";
}
mysql_db_query($db_db,$query);
}
?>Code: Select all
<input type="text" name="<?=$link_id?>" value="<?=$link_order?>" maxlength="3" size="3">If anyone can help with this I would greatly appreciate it!
Thank you