Page 1 of 1
PHP Form with lookup table dropdown list
Posted: Mon May 12, 2008 12:05 pm
by texmansru47
Does anyone know where I can find a good reference of how to incorporate a dropdown list (from a lookup table in my MySQL Database) along with User input data?
Thanks,
Texman
Re: PHP Form with lookup table dropdown list
Posted: Mon May 12, 2008 3:51 pm
by califdon
texmansru47 wrote:Does anyone know where I can find a good reference of how to incorporate a dropdown list (from a lookup table in my MySQL Database) along with User input data?
First you need to understand the HTML for a dropdown box in a form. If you need help with this, try:
http://w3schools.com/html/tryit.asp?fil ... ml_select2.
Then, of course, you need to know the PHP syntax used to connect to a MySQL database and extract the data to be used in a
while loop for all the
<option...>...</option> lines. For this, you might find
http://w3schools.com/php/php_mysql_intro.asp useful.
Re: PHP Form with lookup table dropdown list
Posted: Mon May 12, 2008 8:52 pm
by texmansru47
Thank you for the information, but the second is not really what I need. But there are some great tips there. What I need to find is a reference that could help me decypher the following:
When the user selects the option from the Drop Down List, this creates a variable that will be used to process an Insert from the lookup table into the required table (i.e. to eliminate some human error with excessive typing). What I cannot find is how to (if this is even possible) to take the variable from the selection and use it to pull the correct data from teh lookup table.
I think I need to take that variable and process a query on that lookup table and take the results and insert them into the correct table. Sounds right, but may not be.
Secondly, I need this process to occur without leaving the initial HTML form, and where when the selection is processed the fields in questions are populated with something like a screen refresh, and the user then can complete the other fields data insertion.
These two steps are what I cannot find... I was hoping that a simple reference from Drop Down lists would surfice, but I guess I was wrong... still not sure.
Thanks,
Texman
Re: PHP Form with lookup table dropdown list
Posted: Mon May 12, 2008 9:28 pm
by nowaydown1
There isn't really a simple short example that I could give you to demonstrate what you're trying to accomplish. Ultimately, for the goals you outlined, what you need to be looking at is 'ajax'. You should take a look at this:
http://www.w3schools.com/PHP/php_ajax_database.asp
You would just be adding additional steps to the PHP script that processes your ajax request to do whatever table insertion stuff you need. Hope that helps.
Re: PHP Form with lookup table dropdown list
Posted: Mon May 12, 2008 10:15 pm
by texmansru47
It is closer so thank you for the lead... the problem is, there is where I show my ignorance... I cannot seem to understand how to get that selected data into the appropriate table (same database). It is the simple things that I cannot grasp I guess.
I ran the example they had, but I could not tell whether it worked or did not... fun.
Thanks,
Texman
Re: PHP Form with lookup table dropdown list
Posted: Tue May 13, 2008 11:14 am
by califdon
The problem is that you are asking, in effect, "how do I do step 738 of a 10,000 step process?" Well, I'm exaggerating, of course, but you see my point, I hope. This is something we all do for nearly every project we undertake, but the exact code to do it depends on the rest of the project. If you are interested in learning HTML, CSS, Javascript, PHP and Ajax, you can get a lot of help from the w3schools.com website and other places, including forums like this one. But you can't really expect to ask how to do one tiny piece of a larger project without knowing how to do the rest of it.