You are here: Re: creating form 'select lists' using PHP « PHP Programming Language « IT news, forums, messages
Re: creating form 'select lists' using PHP

Posted by Dikkie Dik on 09/26/05 00:04

phpuser32423 wrote:
> Hi everyone
>
> Is it by any chance possible to use mysql and php to auto create the
> content for drop-down lists on forms by retrieving the values from a
> database? The reason i ask is that on a site i am making i am asking
> users to select from list (e.g. nationality) however i would like to
> avoid typing out every possible value of which there are about 40
> (which change). I would much prefer to keep a seperate table in my
> database for the site.
>
> Kind regards
>
> Mcyi2mr3
>
Sure. I assume the database fields have a numeric ID, so you can get the
ID as an answer while the user only sees the description.
Just fetch all the IDs and Descriptions from the database table (if you
order it by description, the user can type the first letter to select
one). Print the HTML for a dropdown list (<SELECT NAME=...>) and the
options. If you are using the ID, print something like:
'<OPTION VALUE=\'' . $ID . '\'>' . $description
for each record in the table
Make it part of a form and it is submitted with it.

Best regards

 

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

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