error with passing though variables as array
Posted: Tue Sep 12, 2006 3:11 am
I have the following code:
It's passed from a variables such as :
For some reason it only works as it should if the top order variable is ticked before posting. If the top one in the list isn't ticked it doesn't post any of the other information apart from the order variable. Any ideas?
Code: Select all
foreach($_POST['order'] as $orderID=>$orderValue)
{
$amount = current($_POST['amount']);
next($_POST['amount']);
$buy_price = current($_POST['buy_price']);
next($_POST['buy_price']);
$supplier = current($_POST['supplier']);
next($_POST['supplier']);
//update req2
db_query("UPDATE products SET required2=required2-'".$amount."' WHERE product_id='".$orderID."'", 'update_req');
//insert into supplier orders
db_query("INSERT INTO supplier_orders (supplier_id,product_id,amount,price,norm_order) VALUES ('".$supplier."','".$orderID."','".$amount."','".$buy_price."','1')", 'supplier_order');
echo 'O='.$orderID.',S='.$supplier.',A='.$amount.',P='.$buy_price.'<br />';
}Code: Select all
<td align="center"><input type="text" name="<?php echo 'amount['.$srow['product_id'].']'; ?>" id="amount" size="3"></td>
<td align="center">£<input type="text" name="<?php echo 'buy_price['.$srow['product_id'].']'; ?>" id="buy_price" value="<?php echo ''.$srow['buy_price'].''; ?>" size="3"></td>
<td align="center"><input type="checkbox" name="<?php echo 'order['.$srow['product_id'].']'; ?>" id="order"></td>
<td align="center"><input type="checkbox" name="<?php echo 'backorder['.$srow['product_id'].']'; ?>" id="backorder"></td>
<td align="center">