|
Posted by Chris H on 04/01/06 07:19
I have been looking through this script and came across something that I
dont quite understand how it functions or is used. Basically its brackets
that are added on at the end of a form field value.
EXAMPLE:
<input name="eid[]" type="hidden" id="eid[]" value="<? echo $ses_id; ?>">
in other words what does the [] brackets pass to the function thats
processing the form, basically how is the [] used.
Also here is the part of the script that is processing it., as well as the
more coding of the originating form code
===================
// UPDATE BASKET QUANTITY
if (isset($_POST["UpdateChg"])) {
session_start();
include "functions_cart.php";
$i = 0;
$size = count($_POST["eid"]);
for ($i = 0; $i <= $size-1; $i++) {
// call remove bad characters function
$badsymbols = array(" ","-","+","*","/",".");
$_POST["newquan"][$i] = str_replace($badsymbols,"",
$_POST["newquan"][$i]);
if (is_numeric($_POST["newquan"][$i])) {
// if any quantity's equal 0 then remove from cart
if ($_POST["newquan"][$i] == 0) {
unset($_SESSION["cart"][$_POST["eid"][$i]]);
}
// update quantity in cart.
if (array_key_exists($_POST["eid"][$i], $_SESSION["cart"])) {
add_item_to_cart($_POST["eid"][$i], $_POST["newquan"][$i]);
}
} // END IF NUMERIC
}
header ("location:".$_SERVER['HTTP_REFERER']);
} // END BASKET QUANTITY
==============================
===========================
MORE OF THE FORM CODE
<td class="dividingborder"><input name="newquan[]" type="text"
id="newquan[]3" value="<? echo $ses_quan; ?>" size="5" maxlength="4">
<input name="eid[]" type="hidden" id="eid[]" value="<? echo $ses_id;
?>"></td>
===========================
Navigation:
[Reply to this message]
|