Re: Showing multiple option list from db query?

From: Date: Thu, 03 Oct 2002 14:26:03 +0000
Subject: Re: Showing multiple option list from db query?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-22203@lists.php.net to get a copy of this message
> I have a database (mysql) that has some rows entered. > > Format: > Name | Desription | catid > > This has some info in it like this > > Joe Man 1 > Jack Man 1 > Jacky Female 2 > Emily Female 2 > > What I am trying to do is create dynamically created select lists so > that all with catid 1 are in the fisrt select list and all with catid 2 > are in a separate second list and so on. > > I have it nearly working but the first list gives the cadid 1 result the > second gives catid 1 and catid 2 result and so on. > > So how would I split the results? <? $result = mysql_query("SELECT * FROM table"); while($row = mysql_fetch_assoc($result)) { $option[$row['catid']] = "<option value='{$row['Name']}'>{$row['Name']}</option>\n"; } Then use $option[1] and $option[2] in your different select boxes. <select name="male"> <?=$option[1]?> </select> ---John Holmes...

« previous php.db (#22203) next »