Dynamically created textbox would have names in array format.
<input type="textbox" id="textbox[]" name="textbox[]">
If updating dynamically created check box would be:
<input type="checkbox" id="chkbox[]" name="chkbox[]">
$checkbox = $_POST['chkbox'];
$id = "('" . implode( "','", $checkbox ) . "');" ;
$sql = "UPDATE [table] SET [col] = [value] WHERE id IN " . $id . ";
How could I do the same idea with text boxes?
Since you have an UPDATE statement in your question I assume you're sending existing records from your database (having some kind of id) to the client first.
In that case you can put that id in the field name, e.g.
<input type="text" name="text[47] value="..." />
<input type="text" name="text[74] value="..." />
<input type="text" name="text[39] value="..." />
and then on the server side iterate the data like
foreach( $_POST['text'] as $id=>$value ) {
// your database action here, preferably a prepared statement
}
something to play with:
<html>
<head>
<title>...</title>
<style type="text/css">
span.editbtn { cursor: pointer; }
</style>
</head>
<body>
<form method="POST" action="test.php">
<!-- something like this your script would produce from the SELECT query -->
<fieldset class="editgroup"><input type="text" name="post[47]" value="value for id 47" disabled /></fieldset>
<fieldset class="editgroup"><input type="text" name="post[74]" value="value for id 74" disabled /></fieldset>
<fieldset class="editgroup"><input type="text" name="post[89]" value="value for id 89" disabled /></fieldset>
<fieldset class="editgroup"><input type="text" name="post[31]" value="value for id 31" disabled /></fieldset>
<input type="submit" />
</form>
<div id="foo">.</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('fieldset.editgroup').each(function() {
$(this).append('<span class="editbtn">✎</span>');
});
$('fieldset.editgroup').on('click', '.editbtn', function() {
$(this).siblings('input').prop('disabled', false);
});
});
</script>
</body>
</html>
check the result in test.php via <pre><?php var_export($_POST); ?></pre>