gpt4 book ai didi

php - 从所有选中的复选框中获取值并将其插入 MySQL

转载 作者:行者123 更新时间:2023-11-29 21:42:58 25 4
gpt4 key购买 nike

这是我的 HTML:

<input type="checkbox" class="CategoryInput[]" name="categories[]" category="1" value="1" clicked="0">
<input type="checkbox" name="subcategory[]" class="SubCategoryInput1" subcategory="2" value="2" clicked="0">
<input type="checkbox" class="CategoryInput[]" name="categories[]" category="11" value="11" clicked="0">
<input type="checkbox" name="subcategory[]" class="SubCategoryInput11" subcategory="12" value="12" clicked="0">
<input type="checkbox" name="subcategory[]" class="SubCategoryInput11" subcategory="13" value="13" clicked="0">
<input type="checkbox" name="subcategory[]" class="SubCategoryInput11" subcategory="14" value="14" clicked="0">

我的问题是:我如何获取 CategoryInput[]subcategory[] 选中的复选框的值并将它们组合起来如下所示:

$SelectedCheckBoxValues = "1, 3, 4, 6, 2, 7, 3";

然后我必须将它们插入MySQL,我知道我该怎么做,但我需要实现变量$SelectedCheckBoxValues

你能帮我解决这个问题吗?

提前致谢!

最佳答案

 <form action="handler.php" method="get">
<input type="checkbox" class="CategoryInput[]" name="categories[]" category="1" value="1" clicked="0">
<input type="checkbox" name="subcategory[]" class="SubCategoryInput1" subcategory="2" value="2" clicked="0">
<input type="checkbox" class="CategoryInput[]" name="categories[]" category="11" value="11" clicked="0">
<input type="checkbox" name="subcategory[]" class="SubCategoryInput11" subcategory="12" value="12" clicked="0">
<input type="checkbox" name="subcategory[]" class="SubCategoryInput11" subcategory="13" value="13" clicked="0">
<input type="checkbox" name="subcategory[]" class="SubCategoryInput11" subcategory="14" value="14" clicked="0">
<input type="submit" value="submit">
</form>

handler.php

   $values = $_GET['subcategory'];

foreach ($values as $subcategory){
//do something

}

关于php - 从所有选中的复选框中获取值并将其插入 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34341648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com