Re: Populating a Dropdown Menu From a Query

From: Date: Fri, 16 Jul 2004 19:33:24 +0000
Subject: Re: Populating a Dropdown Menu From a Query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-190744@lists.php.net to get a copy of this message
The exact implementation differs with your database system, but as an example for MySQL: <select name="select" size="1"> <?php $result = mysql_query($query); while($row = mysql_fetch_assoc){ echo("<option value=\"{$row['name_of_value_field']}\">{$row['name_of_description_field']}< /option>"); } ?> </select> greetz, Arnout "Harlequin" <michael.mason@arraspeople.co.uk> schreef in bericht news:20040716191823.30635.qmail@pb1.pair.com... > Another day another conundrum. > > I have a form where one option is a dropdown menu. I'd like that menu to > only have items in it that are actually available. Selecting the items with > a query is easy enough but I wondered if anyone could tell me where to start > wit the code. > > Am I using a for each again . . . ? > > Any help greatly appreciated. > > -- > ----------------------------- > Michael Mason > Arras People > www.arraspeople.co.uk > -----------------------------

« previous php.general (#190744) next »