[SOLVED] error passing variable through from <select>
Posted: Mon Sep 11, 2006 8:09 am
I'm passing variables through from a from such as :
They are then used (atm for testing), in the form:
Which works fine for all but the select list. I can't get that to post through and work as the others in the above loop. Any ideas what i'm doing wrong?
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>
<select name="<?php echo 'supplier['.$srow['product_id'].']'; ?>" id="supplier">
<?php if (isset($_POST['suppliers']))
{
$s2 = "SELECT * FROM suppliers WHERE id='".$_POST['suppliers']."'";
$sq2 = mysql_query($s2) or die ("Query $s2 Failed".mysql_error());
$sr2 = mysql_fetch_assoc($sq2);
?>
<option value="<?php echo $_POST['suppliers']; ?>"><?php echo $sr2['name']; ?></option>
<?
}
$s = "SELECT * FROM suppliers";
$sq = mysql_query($s) or die ("Query $s Failed".mysql_error());
while ($sr = mysql_fetch_assoc($sq))
{
?>
<option value="<?php echo $sr['id']; ?>"><?php echo $sr['name']; ?></option>
<?php
}
?>
</select>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']);
echo 'S='.$supplier.',A='.$amount.',P='.$buy_price.'<br />';
}