note 50416 added to reserved.variables

From: Date: Sun, 27 Feb 2005 22:18:32 +0000
Subject: note 50416 added to reserved.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-85646@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/reserved.variables.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50416 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50416&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50416&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50416&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50416&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50416&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50416&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85646) next »