I currently have a form with a table inside of it. I want to pass these values to a php script. What would be my best way to do so? Everything I've searched has not been applicable.
This is how I have my form formatted:
<form id="pageform" action="phpscript.php" method="post">
<table>
<tbody>
<tr>
<td><input type="text" class="nestedInput"name="txtName" value="John"></td><td><input type="text" class="nestedInput" name="txtLocation" value="North St"></td><td><input type="text" class="nestedInput" name="txtAge" value="42"></td>
</tr>
<tr>
<td><input type="text" class="nestedInput"name="txtName" value="John"></td><td><input type="text" class="nestedInput" name="txtLocation" value="North St"></td><td><input type="text" class="nestedInput" name="txtAge" value="42"></td>
</tr>
<tr>
<td><input type="text" class="nestedInput"name="txtName" value="John"></td><td><input type="text" class="nestedInput" name="txtLocation" value="North St"></td><td><input type="text" class="nestedInput" name="txtAge" value="42"></td>
</tr>
</tbody>
</table>
<input type="button" name="btnSubmit" id="btnSubmit" value="Submit">
</form>
The jQuery:
$("#btnSubmit").click(function(){
var array = [];
$(".nestedInput").each(function(n){
array[n] = $(this).val();
});
document.forms["pageform"].submit();
});
My PHP:
<?php
$array=json_decode($_POST['json']);
print_r($array);
?>
What I'd like to do is run a mysqli insert using the values from each input in each tr. Any ideas on how I could do that?