PHP Multiple Selection
0 9403
To select multiple values as a dropdown, 'Foreach LOOP' is used. Now you can easily multiple selection in html dropdown with the help of PHP (Hyper Text PreProcessor Language)
For Example:
<?php if(isset($_POST['subject'])) { $subject_array=$_POST['subject']; $i=0; foreach($subject_array as $key=> $value) { $i++; echo "You choosed <b>" . $value . " </b> . <br>"; } } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> Multiple Selection </title> </head> <body> <h2> Choose your subject</h2> (Hold "ctrl" key to select multiple values) <br> <form action="" method="post" > <select name="subject[]" multiple> <option value="Hindi"> Hindi </option> <option value="English"> English </option> <option value="Mathematics"> Mathematics </option> <option value="Physics"> Physics </option> <option value="Chemistry"> Chemistry </option> <option value="Biology"> Biology </option> <option value="Sanskrit"> Sanskrit </option> </select> <br> <input type="submit" name="sub" value="Submit"> </form> </body> </html>
Share:
Comments
Waiting for your comments