Jump to content


Photo

Help w/ form


  • Please log in to reply
1 reply to this topic

#1 taneya

taneya
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 15 July 2006 - 09:02 PM

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
I am teaching myself PHP - I'm sure to ask a lot of simple and obvious questions!

#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 09:19 PM

simply define a query like so:

SELECT id, name FROM table ORDER BY name ASC

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

<option value="id">name</option>

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:

http://www.phpfreaks...c,100629.0.html




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users