I need help figuring out how to submit data from a table row into PHP to be processed. I would need it to be able to submit multiple rows of data. Any ideas?
I have a table here. I want to be able to check the row and submit the data to php to process the data. It is an HTML table. I just want to know how to pass the variables to php, e.g. an array or something
Ok guys something like this:
$("submit_btn").click(function () {
$('#diary tbody>tr input:checked').each(function() {
$.post('process.php',
data: "an array",
success: "data submitted");
}
});
How would I get the table row data in an array to submit it? (Answer is below)
Ok Part 2:
Sending the table row data to php.
jQuery code:
rows = JSON.stringify(rows); // submit this using $.post(...)
alert(rows);
$.post('classes/process.php', rows, function(data) {
$('#results').html(data);
})
.error(function() { alert("error"); })
});
PHP Code:
<?php
$rowsArray = json_decode($_POST['rows']);
echo $rowsArray;
?>
Error:
Notice: Undefined index: rows in C:...classesprocess.php on line 6
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…