Retrieving Values From A Checkbox
I use a php checkbox and I want to retrieve marked values. My checkbox code :
Solution 1:
You have to change the name attribute to cours[] and then php will treat it as an array.
Read up at http://docs.php.net/faq.html
Solution 2:
You may use some thing like this..
<label for="cours">Je suis intéressé par un ou plusieurs cours :</label><br><br>
<input type="checkbox" name="cours[0]" value="individuel">Individuel<br>
<input type="checkbox" name="cours[1]" value="semiprive">Semi-privé<br>
<input type="checkbox" name="cours[2]" value="minigroupe">Mini-groupe<br>
<input type="checkbox" name="cours[3]" value="intensif">Intensif<br>
<input type="checkbox" name="cours[4]" value="entreprise">Entreprises<br>
<input type="checkbox" name="cours[5]" value="distance">A distance<br>
<input type="checkbox" name="cours[6]" value="telephone">Par téléphone<br>
<input type="checkbox" name="cours[7]" value="coaching">Coaching<br>
<input type="checkbox" name="cours[8]" value="soutien">Soutien scolaire<br>
<input type="checkbox" name="cours[9]" value="diplome">Diplômes officiels<br>
Solution 3:
Print all checkbox value.
<form action="print.php" method="post">
<input type="checkbox" name="val_list[]" value="value 1">
<input type="checkbox" name="val_list[]" value="value 2">
<input type="checkbox" name="val_list[]" value="value 3">
<input type="checkbox" name="val_list[]" value="value 4">
<input type="checkbox" name="val_list[]" value="value 5">
<input type="submit" />
</form>
<?php
if(!empty($_POST['val_list']))
{
foreach($_POST['val_list'] as $data)
{
echo $data;
}
}
?>
Post a Comment for "Retrieving Values From A Checkbox"