Jump to content

form multi array post, foreach not working


SmileyWar

Recommended Posts

Ether i'm extremely tired, or i'm just not seeing my mistakes.

 

But i can't capture the multi arrays for some reason.

 

The jQuery script works correct.

 

It's just the foreach is not working, i don't think i have the form wrong.

 

Any help would be much appreciated, thanks.

 

 

Form on the site

<?php 
echo '<form method="POST" name="addItems" id="addItems12" action="#">'; 
echo '<input type="hidden" name="sessionID" value="'.session_id().'" />';
echo '<input type="hidden" name="newMultiProducts" />';
echo '<input type="hidden" name="productReturnURL" value="Products/Selection/" />';

echo '<input type="hidden" name="item[0][productDescription]" value="Rapid Fit Foot Pack" />';
echo '<input type="hidden" name="item[0][productID]" value="'.$mysql_footpack.'" />';
echo '<input type="hidden" name="item[0][productLink]" value="'.$curURL.'" />';
echo '<input type="hidden" name="item[0][productPrice]" value="'.$_footpack_single_price.'" />';
echo '<input type="hidden" name="item[0][productShipping]" value="A" />'; 
echo '<input type="hidden" name="item[0][productThumb]" value="'.$mysql_footpack.'" />';      
echo '<input type="checkbox" name="item[0][productQuantity]" class="productQuantity" value="1" onClick="toggle(this, \'keynumber_field1\')" />';

echo '<input type="hidden" name="item[1][productDescription]" value="Rapid Fit Foot Pack" />';
echo '<input type="hidden" name="item[1][productID]" value="sh_'.$mysql_footpack.'" />';
echo '<input type="hidden" name="item[1][productLink]" value="'.$curURL.'" />';
echo '<input type="hidden" name="item[1][productPrice]" value="'.$_footpack_single_2ndhand_price.'" />';
echo '<input type="hidden" name="item[1][productShipping]" value="A" />'; 
echo '<input type="hidden" name="item[1][productThumb]" value="'.$mysql_footpack.'" />';      
echo '<input type="checkbox" name="item[1][productQuantity]" class="productQuantity" value="1" onClick="toggle(this, \'keynumber_field2\')" />';

echo '<input name="add_to_basket" type="image" id="submit12" src="img/addtobasket_new.png" 
alt="Click here to add items to your shopping basket" />';

echo '</form>';
?>

 

 

jQuery

$(document).ready(function() {
$("#submit12").click(function(){
		$(".preloaderMiniBasketBG").fadeIn(300);
		$('.preloaderMiniBasket').html('<img src="images/styling/preloaderTP.gif" />');
		$.ajax({  
			type: "POST",  
			url: "Shopping/json.php",  
			data: $("#addItems12").serialize(),  
			dataType: "json",  
			success: function(data){
				/*
				if (data.productReturnURL){
					window.location.href = data.productReturnURL;
					}
				*/
				console.log(data);
				$('#miniBasket').html(data.miniBasket);
				$('#miniBasketDetails').html(data.miniBasketDetails);
				$('.preloaderMiniBasket').html('');
				$(".preloaderMiniBasketBG").fadeOut(300);
				$("#miniBasketPopup").fadeIn(300);
				setTimeout(function() {
					$("#miniBasketPopup").fadeOut(2500);
				},5000);
			}						
		});
		return false;
	});
});

 

 

the script that runs the foreach

foreach($_POST['item'] as $key => $value)
	{

		$productDescription = $value['productDescription'];
		$productID = $value['productID'];
		$productKeyNumber = $value['productKeyNumber'];
		$productLink = $value['productLink'];
		$productPrice = $value['productPrice'];
		$productQuantity = $value['productQuantity'];
		$productShipping = $value['productShipping'];
		$productThumb = $value['productThumb'];
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.