----- Original Message ----- From: "Dan Phiffer" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 10, 2003 11:24 AM Subject: [PHP] Multi-select inputs and naming
> Hello, > > Am I correct in my understanding that for a multi-select input, PHP requires > that the name attribute end with square brackets (i.e. <select > name="my_select[] multiple>") in order for the submission be handled > properly? > > I know this is somewhat nit-picky, but this seems to unnecessarily expose > the underlying technology such that scanning the HTML source reveals that a > PHP script will ultimately parse the submission. > > I'm hoping there's some alternative technique I've missed... > > -Dan Yes. The values must be passed as an array. In order to do that the select tag requires the [] braces. The proper syntax is: <select name="my_select[]" multiple> <option>One</option> <option>Two</option> <option>Three</option> </select> <? // To read the selected items... for($i=0; $i<count($_POST['my_select']); $i++) { echo $_POST['my_select'][$i]."<br>"; } ?> Hope that helps. - Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php