You are here: Re: Populating <options> tag with SQL data? « PHP Programming Language « IT news, forums, messages
Re: Populating <options> tag with SQL data?

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация