kirkh34 Posted November 19, 2010 Share Posted November 19, 2010 i have a shopping cart set up with mysql with a $_COOKIE['cart_id'] used to call all rows with cart_id... i have a while loop print out all the items in the cart $sql2 = mysql_query("SELECT * FROM cart WHERE cart_id = '$cart_id'") or die(mysql_error()); while($row = mysql_fetch_array($sql2)){ then i have it echo out the name...desc... quantity of each item... but the quantity is set up to be able to change and i have a form set up and i'd like to have each item be able to be changed at once if they wanted....but being multiple rows... there could be multiple $_POST['quantity']... echo "<td><input type='text' name='quantity' value='".$quantity."'/></td>"; there is a unique id for each row in the table that i'd like to set up with an array to post... i'd like to set up an array $array[$uniq_id] => $quantity; and somehow POST this array name='$array[]' and then on the action end... be able to call it by having foreach($quantity as $uniq_id => $qty){ mysql_query("UPDATE cart SET quantity='$qty' WHERE id='$uniq_id' "); } i'm not sure if i'm approaching this the right way... the array part is leaving me stuck...any help is appreciated..thank you! Quote Link to comment https://forums.phpfreaks.com/topic/219237-post-array-and-receiving/ Share on other sites More sharing options...
sasa Posted November 19, 2010 Share Posted November 19, 2010 change form part to echo "<td><input type='text' name='quantity[".$uniq_id."]' value='".$quantity."'/></td>"; and on action page do foreach($_POST['quantity'] as $uniq_id => $qty){ mysql_query("UPDATE cart SET quantity='$qty' WHERE id='$uniq_id' "); } Quote Link to comment https://forums.phpfreaks.com/topic/219237-post-array-and-receiving/#findComment-1136926 Share on other sites More sharing options...
kirkh34 Posted November 19, 2010 Author Share Posted November 19, 2010 awesome! that works perfect... thanks so much!! very much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/219237-post-array-and-receiving/#findComment-1136932 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.