RE: (HTML related) helping to creating dropdown lists from fetched arrays.

From: Date: Sun, 24 Feb 2002 23:05:48 +0000
Subject: RE: (HTML related) helping to creating dropdown lists from fetched arrays.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-86024@lists.php.net to get a copy of this message
it does help a little. I know the html is wrong I used this as an example to what I wanted. What I need to know is how to use PHP to generate the options in the list from col1 and show the option 2. The data for these is got from an array. so really what I want to know is how to code in PHP <select name=test drop down> <option value=col1($row1)>col2($row1) <option value=col1($row2)>col2($row2) <option value=col1($row3)>col2($row3) </select> you get the idea ? Thanks, Matt. -----Original Message----- From: Cece [mailto:cece@balaton.hu]On Behalf Of Heilig (Cece) Szabolcs Sent: 24 February 2002 23:07 To: php-general@lists.php.net Cc: matthew@darcy.demon.co.uk Subject: OT:(HTML related) helping to creating dropdown lists from fetched arrays. > I want to create a dropdown list with options from a table. > <?php > > $sql_select = "select * from dropdown_options"; > $results = mysql_query($sql > _select); > > while ($row = mysql_fetch_array($results); > { > echo "<option VALUE=$row["col1"] NAME=option1>" > } Hi! The problem is simple: wrong HTML You have to make html code similar that: <select name=gender> <option value=F>female <option value=M>male <option value=0>not known :) </select> Hope it helps Cece

« previous php.general (#86024) next »