技术:HTML,JS,PHP,MySQL
我有一些动态创建的数据行。现在我想更新一些由用户检查进行编辑的行。它可能是所有行或其中一些。喜欢这个
我创建了这些行的ID,例如" checkbox_ [数据库中的数据ID]"
现在我想更新数据。如何使用$ _POST更新已检查的ID?
答案 0 :(得分:1)
<form action="test.php" method="post">
<input type="checkbox" name="check_list[]" value="value 1">
<input type="checkbox" name="check_list[]" value="value 2">
<input type="checkbox" name="check_list[]" value="value 3">
<input type="checkbox" name="check_list[]" value="value 4">
<input type="checkbox" name="check_list[]" value="value 5">
<input type="submit" />
</form>
<?php
if(!empty($_POST['check_list'])) {
foreach($_POST['check_list'] as $check) {
echo $check; //echoes the value set in the HTML form for each checked checkbox.
//so, if I were to check 1, 3, and 5 it would echo value 1, value 3, value 5.
//in your case, it would echo whatever $row['Report ID'] is equivalent to.
}
}
?>