php - 如何在 PHP 中选择数据库 mysqli 表中的复选框
问题描述
**如何在数据库 mysqli 中选择复选框我应该在复选框值中写什么请帮助我还将数组转换为字符串的内爆函数没有找到要打印的复选框值的值。.....还要检查图片上的输出... **
<?php
while($fetch=mysqli_fetch_array($select))
{
?>
<tr>
<td><?php echo $fetch["tableno"]?></td>
<td><?php echo $fetch["customerid"]?></td>
<td><?php echo $fetch["item"]?></td>
<td><?php echo $fetch["money"]?></td>
<td><a href="javascript:del_tableno(<?php echo $fetch["tableno"];?>)"><button>Delete</button></a></td>
<td><a href="update.php?tableno=<?php echo $fetch["tableno"]; ?>"/><button>Update</button></td>
<td><form method="POST">
<input type="checkbox" name="chk[]" value="???">
<input type="submit" name="sub1" value="Button for Checkbox">
</td> </form>
</tr>
<?php
}?>
</table>
<p style="font-size:30px">The Customer has TO Selected these Items from Menu List
and therefore submitted to<br> Kitchener to Make the Food and
then waiter will serve the Food to Customer.</p>
</body>
</html>
<?php
if(isset($_POST['sub1']))
{
$chk=implode(',', $_POST['chk']);
echo "<br>Customer has selected the following checkbox Item to be Prepared and Eat the Food:<br/>";
echo "<br/>".$chk."<br><br/><br/><br/><br/>";
}
?>
解决方案
试试这个:
在您的表单中,插入多个复选框的方法
<form method="POST" action="test2.php">
<input type="checkbox" name="chk[]" value="InputText1">InputText1<br>
<input type="checkbox" name="chk[]" value="InputText2">InputText2<br>
<input type="submit" name="sub1">
</form>
if(isset($_POST['sub1'])) // check the submitted form and print the values
{
echo "You selected the following checkbox:<br/>";
foreach ($_POST['chk'] as $value) {
echo $value."<br>";
}
推荐阅读
- javascript - 表单提交后如何重置表单并启用提交按钮(react-formio)?
- c# - 我需要注册 c# 表单的帮助
- user-interface - 不兼容的类型:void 不能转换为 String
- r - R:每月汇总行数
- r - 在 r 中使用 gtrends 循环下载多个关键字的 Google 搜索数据
- maven - 了解 Tycho 错误编译:缺少要求
- api - Instagram Api 错误代码 400 无效响应类型
- winapi - 如何检查相对路径是否存在
- c++ - 如何在 C++ 中打印学生的成绩(学生班级)
- laravel - Laravel 包:Route:resource() 不传递参数