|
Posted by Tom on 05/03/07 17:43
On 3 May 2007 07:37:49 -0700, cresh wrote...
>
>Hello everyone,
>
>I have a problem that I cannot seem to figure out. If any of you have
>an answer or suggestion, I would appreciate it.
>
>My HTML/PHP code needs to pull options from a database to populate the
><options> tag for a drop down menu and I cannot get it to work.
>
>Basically, there is a form on the website with a drop down box. I need
>the options in this box to be pulled from a preexisting table in a
>database. That's all. Sounds very simple but I'm totally lost on how
>to accomplish it.
>
>Any help would be greatly appreciated.
>
>Thank you,
>
>Cresh
>
If you are getting results back from your database (e.g. MySQL), you can use a
"while" loop to collect the information. This link at the PHP site would cover
it in more detail
http://www.php.net/manual/en/function.mysql-db-query.php
but once you have the query setup you can built that into a variable such as...
$option = '';
while ($row = mysql_fetch_assoc($result))
{
$option .= "<option>" . $row['ColumnName'] . "</option>";
}
Tom
--
Basic Accounts $5.95 / month or $39.95 / 12 months
[Back to original message]
|