[PHP-DB] multiple selections to input variables
I have a form with a multi-line select field: select name=cities size=5 multiple ? $sql=select City from table group by City ; $result = mysql_query($sql) or die($sql . mysql_error()); while($row=mysql_fetch_object($result)) { $city = $row-City; $cityCode = strtolower(eregi_replace( ,_, $city)); $cityName = ucwords(strtolower($city)); echo(OPTION value='$cityCode'$cityName/OPTION); } } ? /SELECT and I am trying to read the multiple selections on the process form, but only seeing the last selected item. [ sample parameter list based on get method ] filename.php?cities=waterfordcities=wintoncities=woodbridge [snip] if($cities) { // multiple may be selected -- figure that out later die(multiple cities: $cities);// results in displaying 'multiple cities: woodbridge' } [snip] I'm using PHP and MYSQL to hold the results. Terry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] multiple selections to input variables
On Thursday 18 July 2002 23:18, Terry Romine wrote: I have a form with a multi-line select field: select name=cities size=5 multiple Use: select name=cities[] size=5 multiple if($cities) { // multiple may be selected -- figure that out later die(multiple cities: $cities);// results in displaying 'multiple cities: woodbridge' } You can then use: foreach ($cities as $value) { echo Selected $valuebr; } -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* The discerning person is always at a disadvantage. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] multiple selections to input variables
Great!! Works like a charm. Terry On Thursday, July 18, 2002, at 10:27 AM, Jason Wong wrote: On Thursday 18 July 2002 23:18, Terry Romine wrote: I have a form with a multi-line select field: select name=cities size=5 multiple Use: select name=cities[] size=5 multiple if($cities) { // multiple may be selected -- figure that out later die(multiple cities: $cities);// results in displaying 'multiple cities: woodbridge' } You can then use: foreach ($cities as $value) { echo Selected $valuebr; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php