check boxes are frequently used in Web forms, so how do you use PHP to determine which checkboxes in a submitted form are selected and read the data in them?
First create a form: form.html
Copy the Code code as follows:
Then create a program that processes the form: checkbox.php
Copy the Code code as follows: <?php
$a =$_post["s"];
Print_r ($a);
?>
This can be shown in the form of arrays, which are selected. Display results similar to: Array ([0]=7 [1]=15]
However, the above program is only used to show whether the check box is normal, if you remove all the data in the array, you need to use the loop.
So the program is further modified to: checkbox.php
Copy the Code code as follows:
<?php
$a =$_post["s"];
for ($i =0; $i<>
{
echo "Options". $a [$i]. " is selected
";
}
?>
The result of this execution is similar to the following:
Copy the Code code as follows: Option 3 is selected
Option 15 is selected
I believe the next step is more convenient to execute other statements.
http://www.bkjia.com/PHPjc/824834.html www.bkjia.com true http://www.bkjia.com/PHPjc/824834.html techarticle check boxes are frequently used in Web forms, so how do you use PHP to determine which checkboxes in a submitted form are selected and read the data in them? First create a form: form.html ...