Re: Getting data from mysql db for html form
| From: | Torsten Roehr | Date: | Wed, 09 Jun 2004 17:46:52 +0000 |
| Subject: | Re: Getting data from mysql db for html form | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-34687@lists.php.net to get a copy of this message | ||
"Gamco - Gawie Marais" <gawie@gam.co.za> wrote in message
news:200406091404.i59E4TjH007936@lightning.gam.co.za...
> Hi,
>
> Could someone help me out here...
>
> I have a mysql database with a table that conatains names. I am setting up
a
> html form and I would like to create a multi-listing with those names so
> that you can choose one and then submit the form.
// open db connection...
$result = mysql_query("SELECT name FROM table");
echo '<select name="names">';
while ($row = mysql_fetch_assoc($result)) {
echo '<option>' . $row['name'] . '</option>';
}
echo '</select>';
Haven't tested it. Change 'name' to the name of your table column.
Regards,
Torsten Roehr