将复选框值的多行保存到数据库中
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将复选框值的多行保存到数据库中相关的知识,希望对你有一定的参考价值。
I have been trying to solve my problems on stackoverflow, but none seems to help. Hopefully someone here could help me.
<tbody id="dataTable"> <tr> <td> <input type="text" class="form-control" name="startTime[]"> </td> <td> <input type="text" class="form-control" name="endTime[]"> </td> <td> <input type="checkbox" name="Monday[0]" value="1"> </td> <td> <input type="checkbox" name="Tuesday[0]" value="1"> </td> <td> <input type="checkbox" name="Wednesday[0]" value="1"> </td> <td> <input type="checkbox" name="Thursday[0]" value="1"> </td> <td> <input type="checkbox" name="Friday[0]" value="1"> </td> <td> <input type="button" class="btn btn-danger" value="Delete" onClick="deleteRow('dataTable')" /> </td> </tr> </tbody> //handleschedule.php// <?php } else { if ($_POST['startTime']) { foreach ($_POST["startTime"] as $key => $value) { $endTime = $_POST["endTime"][$key]; $sql = "INSERT INTO timetableschedule ( startTime, endTime, Monday, Tuesday, Wednesday, Thursday, Friday) " . "VALUES ('$value', '$endTime', '$monday', '$tuesday', '$wednesday', '$thursday', '$friday')"; } } echo "1 record added"; } ?>
以上是关于将复选框值的多行保存到数据库中的主要内容,如果未能解决你的问题,请参考以下文章
将控件值(多行文本框、NumericUpDowns、复选框)保存到文件/从文件中加载
如何通过单击适配器类中代码的项目中的删除按钮来删除列表视图中的项目后重新加载片段?