Jump to content

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/14706-help-w-form/
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:

[url=http://www.phpfreaks.com/forums/index.php/topic,100629.0.html]http://www.phpfreaks.com/forums/index.php/topic,100629.0.html[/url]
Link to comment
https://forums.phpfreaks.com/topic/14706-help-w-form/#findComment-58671
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.