infolink

Wednesday, 25 February 2015

PHP Multiple Checkbox Array

This example shows how the programmer can use multiple checkbox array and display the values of selected checkboxes.

Multiple Checkbox Array
Multiple Checkbox Array

PHP Code:

<form method='post' id='form1' action='CheckboxArray.php?process'> 
<table> 
<tr>
    <td>Checkbox Array Example. Select from below</td>
</tr>
<tr>
    <td>
    <input type='checkbox' name='checkboxarray[]' value='checkbox 1'>checkbox 1<br>
    <input type='checkbox' name='checkboxarray[]' value='checkbox 2'>checkbox 2<br>
    <input type='checkbox' name='checkboxarray[]' value='checkbox 3'>checkbox 3
    </td> 
</tr> 
</table> 
<input type='submit' id="submit" value="Click"> 
</form>

<?php 
if (isset($_GET['process'])) 
{
echo "you Selected: ";
foreach($_POST['checkboxarray'] as $value)
{
echo $value."\t"; 
}
}
?>


Note:

Copy and paste this code and save the file with the name of "CheckboxArray.php" and enjoyed.

OUTPUT


Multiple Checkbox Array
Multiple Checkbox Array

2 comments:


  1. I am newbie of this PHP technology, this post helps me to know the introductory of PHP, Thanks for posting such a nice post.
    Regards,
    PHP Training in Chennai|PHP Course in Chennai

    ReplyDelete
  2. Thanks for sharing informative article on web design and development. As every business is moving towards online marketing, there is huge demand for trained and skilled web designers and developers. Web designing Training in Chennai

    ReplyDelete