Re: How to Add Dropdown List items on the fly?

From: Date: Sun, 05 Nov 2000 08:26:01 +0000
Subject: Re: How to Add Dropdown List items on the fly?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-23772@lists.php.net to get a copy of this message
let's say you are grabbing one column (select my_column from my_table;) from a MySQL DB <SELECT name="my_select"> <? while($row = mysql_fetch_array($result_set)) { echo "<OPTION value=\"$row[my_column]\">$row[my_column]</OPTION>\n"; } ?> </SELECT> what this does essentially is open the select tag, go into PHP processing mode, and loop through the results printing new <OPTION> tags with the result each time, and then moves back to HTML mode and then closes the <OPTION> tag. If this doesn't make sense, you could try reading docs on the mysql functions in PHP, and I believe there is a tutorial at www.webmonkey.com I didn't execute this code, but it should work fine. Hope this helps, Jeff Davis jing zhao wrote: > Hi, > > once I have got the resultset from a database query, > and I want to populate a dropdown list with the results, > what is the proper syntex for adding all the rows? > > thanks in advance. > > jing > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#23772) next »