Here is my 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">
My question is: How can i get the values for the checked checkboxes for CategoryInput[]
and subcategory[]
and combine them to look like that:
$SelectedCheckBoxValues = "1, 3, 4, 6, 2, 7, 3";
Then i have to insert them into MySQL, i know how can i do that, but i need to achieve the variable $SelectedCheckBoxValues
.
Can you help me out with that.
Thanks in advance!
<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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.