Jump to content


This topic is now archived and is closed to further replies.


Help w/ form

Recommended Posts


I am a relative newbie with PHP and have two questions that I'm hoping someone can help me understand how to do:

1. I have made a webform that has five input fields for entering data into a mysql table. One of the fields on my form I would like the user to select from a defined list of options. However, I would like this list to be extracted from my database, and not one that I have to hardcode the options.

2. For this same field, the list that the user would select from is a name. However, there is another table in my database that assigns this name and ID number and it is in fact this ID number that needs to go into the particular table that my form is set up to enter into. Is there a statement that I can write that will let the person select the name, but then what is entered into the form is actually the ID number?

I can provide more detail if needed, but any insight would be most helpful!


Share this post

Link to post
Share on other sites
simply define a query like so:

[code]SELECT id, name FROM table ORDER BY name ASC[/code]

go through it and echo an option tag for each id and name set in the following format:

[code]<option value="id">name</option>[/code]

this will send the ID rather than the name, but will display the name to the user.  for help on going through a MySQL query and processing the rows it grabs, see my post in this topic:


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.