taneya Posted July 15, 2006 Share Posted July 15, 2006 Hi, 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!Taneya Quote Link to comment https://forums.phpfreaks.com/topic/14706-help-w-form/ Share on other sites More sharing options...
akitchin Posted July 15, 2006 Share Posted July 15, 2006 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:[url=http://www.phpfreaks.com/forums/index.php/topic,100629.0.html]http://www.phpfreaks.com/forums/index.php/topic,100629.0.html[/url] Quote Link to comment https://forums.phpfreaks.com/topic/14706-help-w-form/#findComment-58671 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.