I have this code bellow:
<?php
if(isset($_SESSION["products"])) {
$total = 0;
echo '<form action="cart-post-config.php" enctype="multipart/form-data" method="POST">>';
foreach ($_SESSION["products"] as $cart_itm) {
echo '<tr>';
echo '<td></td>';
echo '<td><input type="text" name="product_name[]" value="'.$cart_itm["name"].'"/></td>';
echo '<td><input type="text" name="product_price[]" value="'.$cart_itm["price"].'"/></td>';
echo '<td><input type="text" name="product_quantity[]" value="'.$cart_itm["qty"].'"/></td>';
$totalPerEach = ($cart_itm["price"]*$cart_itm["qty"]);
echo '<td><input type="text" name="product_eachTotal[]" value="'.$totalPerEach.'"/></td>';
echo '<td>View Save Delete</td>';
echo '</tr>';
}
echo '<input type="submit" name="submit" />';
echo '</form>';//close the form
}
else {
echo 'Your Cart is empty'; }
?>
The code above is used to collect the cart information of the member, where the information that has been collected are putted to the input of the form that will be posted to the database.
This is the config:
if($_SERVER["REQUEST_METHOD"] == "POST")
{
for($i=0; $i<count($_POST['product_name']);$i++)
{
$product_name=$_POST['product_name'][$i];
$product_price=$_POST['product_price'][$i];
$product_quantity=$_POST['product_quantity'][$i];
$product_eachTotal=$_POST['product_eachTotal'][$i];
mysql_query("insert into member_cart (cart_code, product_cart_name, product_cart_price, product_cart_quantity, total_cart_price)
values(0, '$product_name', '$product_price', '$product_quantity', '$product_eachTotal')");
}
}
The config above will be read the form that will be posted where will loop the row of eahc products that have been added to the chart.
My problem now is after posting the form, the row of product_cart_quantity
and the row of total_cart_price' only got the text/data of
Array` in the database.
Please help I don't have any idea what I am doing wrong here.
Thanks