Given a list of items and the task is to retrieve the multiple selected value from a select box using PHP.
Use multiple attribute in HTML to select multiple value from drop down list. Selecting multiple values in HTML depends on operating system and browser.
- For window users – hold down + CTRL key to select multiple option
- For mac users – hold down command key to select multiple option
Example: This example creates a list of items using HTML.
|
Now, the task is to retrieve or print multiple selected value from list. Use form method and loop to retrieve selected value in PHP.
Example:
|
Output:
Note: The form can be submitted using $_GET method. It depends on the form method=”?” value.