SmileyWar Posted July 17, 2012 Share Posted July 17, 2012 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']; } Quote Link to comment https://forums.phpfreaks.com/topic/265839-form-multi-array-post-foreach-not-working/ Share on other sites More sharing options...
SmileyWar Posted July 17, 2012 Author Share Posted July 17, 2012 I singled out the script to run on itself without any problems. So i'll have to look somewhere else. I'll close this topic for now. Quote Link to comment https://forums.phpfreaks.com/topic/265839-form-multi-array-post-foreach-not-working/#findComment-1362214 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.