I have a form with a few rows that I am trying to insert the values into the database. I am using jquery serialize to send the ajax post to the page. At this point, I am lost for how to send the values properly in an array so I can get the values. There are approx 10 rows with the same input id's. Quantity, Price, Part Number. I send all ten to the php page. I need to retreive these ten rows and insert. Any help is appreciated. Here is the code.
<form id="form">
////These row repeat. Total of 10
<input name="PartQuantity[]" type="text" id="PartQuantity" size="2" />
<select name="PartType[]" id="PartType">
<input name="PartNumber[]" type="text" id="PartNumber" size="10" />
</form>
jquery
<script>
$(document).ready(function(){
$('.showResults').live('click', function() {
var post = $('#form').serialize();
jQuery.ajax({
type: "POST",
url: "ajax/page_activity/forms/insert_parts.php",
data: post,
cache: false,
success: function(html)
{
alert(html)
}
});
});
});
</script>
php page
<?php
$quantity_array = $_POST['PartQuantity'];
foreach ($quantity_array as $quantity)
{
///insert values
}
?>
I can only print out the values for one of these arrays, not all of them.