Re: put a lot of items in a shopping cart at once
- From: "ccisystems" <cristi.cotovan@xxxxxxxxx>
- Date: 6 Oct 2005 07:26:42 -0700
You have to use an associative array to accomplish that. You put in the
quantity specification form items like this:
<input type='text' name='itemqty[72132]' value="" />
and then, the quantity inserted in the field by the user will be in the
other part of the array, so basically you will get, when posting this
form back, an array like:
"itemqty[7132]" -> "1", "itemqty[3245]" -> "1", ...
and then se a for each loop with key and value (key is 7132, 3245) and
value is the quantity entered in the field:
$itemqty = $_POST["itemqty"];
while (list ($key, $val) = each ($itemqty)) {
if ($val <> "0") {
$upq = "insert into `shopping_cart` values ( `quantity` =
'$val') where `item_id` = '$key'";
};
$upr = mysql_query($upq) or die ("Cannot INSERT quantities:
".mysql_error());
};
....i hope this helps.
.
- References:
- put a lot of items in a shopping cart at once
- From: Mike Biggi
- put a lot of items in a shopping cart at once
- Prev by Date: help with preg_replace()
- Next by Date: PHP_INI_PERDIR on Windows
- Previous by thread: put a lot of items in a shopping cart at once
- Next by thread: overlading constructor and functions in PHP 4
- Index(es):
Relevant Pages
|