Re: How do I populate a select?

From: Date: Tue, 10 Dec 2002 15:25:38 +0000
Subject: Re: How do I populate a select?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127656@lists.php.net to get a copy of this message
echo("<select name='...'>") while ($array = mysql_fetcharray($mysql)) { echo("<option>{$array["catname"]}</option>"); } echo("</select>") that's the simple version - you may want to put the whole lot inside ... if (mysql_numrows()) { ... } else { echo("warning"); } I may have got the function names wrong - I use an abstraction layer these days Tim Ward http://www.chessish.com mailto:timward@chessish.com ----- Original Message ----- From: Steve Jackson <stephen.jackson@violasystems.com> To: PHP General <php-general@lists.php.net> Sent: Tuesday, December 10, 2002 3:24 PM Subject: [PHP] How do I populate a select? > How do I populate a select list with a list of category names from a DB? > I can select the names using a query but how do I loop through them to > display them in a select? > > My query below will return the cat names. (when I do something with it > like echoing the result) > > $mysql = mysql_query("SELECT catname FROM categories ORDER BY catid"); > > But I want to give each catname in the DB a unique name in a form select > and don't know how to go about it. > Tutorials or tips anyone? > Regards, > > Steve Jackson > Web Developer > Viola Systems Ltd. > http://www.violasystems.com > stephen.jackson@violasystems.com > Mobile +358 50 343 5159 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#127656) next »