I am attempting to populate an HTML drop down menu based on the selection from a previous drop down menu and access to MySQL Database fields. I would like to populate three drop downs in total based on the data contained in the MySQL database. I already have built and have access to my database.
How often does this data change? Usually for data that isn’t mission critical, I use a scheduled task or a cronjob to write out the information to a flat file that I can just use a <?php include(‘path to file’); ?> on so the HTML is already built and can be easily included into your document. Then I schedule the task or cronjob to run nightly, weekly, whatever makes sense.
Thank you for the recommendation and welcoming–most of what I’ve found already is AJAX oriented–I’ll give that a shot. The Make, Model and Year values update per annum, but I do have other variables that will update as quickly as every five minutes. Sorry, StarLion, but I wish I was still in school. I’m a few years beyond that now and am just getting into server-side scripting.
In school or out, we could all stand to learn a few things
If I understand you correctly, you have an initial form containing “common to all” selects, that when once chosen will lead to specific “not common to all” choices.
So maybe something like this:
Initial page populates the select with the “common” values taken from the database.
Form sends input values to server.
Server finds applicable “specific” values and sends back a second form using those values.
Form sends those input values to the server.
Server sends back the final page.
You may be interested in using the QuickForm2 package as it would save you from a lot of work.
This package provides methods to create, validate and render HTML forms.
Supports all form elements defined by HTML standard, provides several
Server-side and client-side validation, several common rules provided
Multipage forms (tabbed forms and wizards)
Pluggable elements, rules, renderers and renderer plugins
Major advantages over PHP4 version:
Most of the package’s functionality is covered by unit tests
DOM-like API for building the form structure, new streamlined API for
elements’ values handling
Default rendering without tables (inspired by
Renderer plugins for elements with complex rendering needs
Ability to chain validation rules with ‘and’ and ‘or’
Client-side validation can run “live” on changing the form fields,
validation errors are displayed near the fields instead of in alert()