Generally speaking, only the value of the last checkbox is always obtained in PHP, so how can we obtain the values of all checkboxes?
The solution is as follows:
Part of the code of the form is as follows:
<input type="checkbox" name="frm_tag[]" value="1">1 <input type="checkbox" name="frm_tag[]" value="2">2 <input type="checkbox" name="frm_tag[]" value="3">3 <input type="checkbox" name="frm_tag[]" value="4">4 <input type="checkbox" name="frm_tag[]" value="5">5
The code for PHP to process the data passed by POST is as follows:
$str_tag = ""; $frm_tag = $_POST['frm_tag']; for($i=0;$i<count($frm_tag);$i++){ echo $frm_tag[$i]."<br>"; if($i==0) $str_tag = $frm_tag[$i]; else $str_tag = $str_tag.",".$frm_tag[$i]; } echo $str_tag; }
I believe that what is described in this article has certain reference value for everyone to have a deep understanding of PHP programming.
Yes, the checkbox in the form will not be submitted if there is no selection.
That’s why it is prompted.
==========
You can judge it before outputting it. .
if(isset($_POST["orange"])) echo $_POST["orange"];
Wow, I just did this. The checkbox is an array and you have to put them in the array.
The principle is: pass those values over. Then convert them into non-arrays
For example:
29
30
31
32
These forms
$waistline=$_POST["waistline"];
$myallsport = implode (" ,", $waistline);
In this way, just insert $myallsport into it