Here I load a table with an option to input a quantity.
<?php
while ($row=mysql_fetch_array($select))
{
?>
<td><?php echo $row['Size'];?></td>
<td><input type="text" name="[<?php echo $row['Id'];?>]" id="[<?php echo $row['Id'];?>]"></td>
<?php
}
?>
When submitting the form I want to post all the inputs+ID to the next page through Ajax.
$(document).ready(function() {
var table = $('#Productslist').DataTable();
$('button').click( function() {
var data = table.$('input').serialize();
$.ajax({
data: data.substr( 0, 120 ),
url: 'confirmorder2.php',
method: 'POST', // or GET
});
});
} );
Here I try to get each row where ID=$name
and input=$value
. If the input is empty they do not get echo out.
<?php
foreach($_POST as $name => $value)
{
if (!empty($value)) {
?>
<tr>
<td><?php echo $name;?></td>
<td><?php echo $value;?></td>
</tr>
<?php
}
}
?>
The only thing I get echo'd on the next page is my token name and token which I have in a hidden input.