note 50416 deleted from reserved.variables by philip
| From: | philip@php.net | Date: | Wed, 21 Feb 2007 16:13:50 +0000 |
| Subject: | note 50416 deleted from reserved.variables by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123655@lists.php.net to get a copy of this message | ||
Note Submitter: x_terminat_or_3 at [remove] yahoo.fr
----
I didn't find it anywhere here and I was ready to bang my head on the wall until I found the
solution!
So when you use a select with multiple options you have to cheat to let php recognize it.
When processing the request, php puts all selected options in the select object's name, but
treats it like an array. If it is not an array, only the last option is remembered.
So to cheat you should append [ ] to the name of the select
<form .. ... ..>
<select multiple="multiple" name="myselect[]" size="3">
<option value="1">1st option</option>
<option value="2">2nd option</option>
<option value="3">3rd option</option>
...
Then in the processing part:
<?php
if(!empty[$_REQUEST['myselect']) print_r($_REQUEST['myselect']);
?>
Will show you the array with all the selected options