Basic "Form" & "Database" concept

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
mjs1138
Forum Newbie
Posts: 3
Joined: Wed Dec 23, 2009 8:55 am

Basic "Form" & "Database" concept

Post by mjs1138 »

I'm building a FORM that will allow a user to enter info into a MySQL DB. The form presents the user w/ some select / pull-downs to select some of the info to be added to the db. The options in the selects are loaded from tables already in the db. The users want to select a value from one pull down (pull-down-A) and have the subsequent value of other pull downs (pull-down-B, pull-down-C, ...) restricted by the value picked in pull-down-A)

Not having done this before and guessing that it's not an uncommon procedure I'm hoping someone can tell me how this is normally accomplished. A possible solution I've thought of is to load the page w/ hidden html and use java script to do the manipulating of the option values in the selects.

Any thoughts will be appreciated.

Thanks --- Mike
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: Basic "Form" & "Database" concept

Post by JNettles »

Cascading drop downs. Yes, you will need Javascript to do this (smoothly). It actually shouldn't be that hard. You'll just need to change dropdowns based on the value of another dropdown when one is changed.
mjs1138
Forum Newbie
Posts: 3
Joined: Wed Dec 23, 2009 8:55 am

Re: Basic "Form" & "Database" concept

Post by mjs1138 »

JNettles, thank you. Looks like just what I was looking for.

Thanks --- Mike
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Basic "Form" & "Database" concept

Post by omniuni »

Another possible solution if you want to avoid JS is to present the form in a "step-by-step" manner. Let the user enter information, and click "next". POST the information to the next page which will store it as hidden values, and present the appropriate related drop-down, while indicating that they are on "step two".
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Basic "Form" & "Database" concept

Post by josh »

I built an entire software product based on the idea. You could view my demo sites on http://www.vehiclefits.com, the jquery code is not obfuscated or encrypted in any way.
Post Reply