Free use for all... do whatever you will to it.
I got tired of writing code for Select Drop Downs in forms so I decided to make an object.
You feed it a SQL Query, a name for the select box, the Mysql field to be displayed, the mysql field to use as the value of each select option.
Optional fields for selected field and selected value. Selected field is not yet implemented (and I'm not sure I ever will) but if you choose to have a value selected at the start of the form load (as in when you edit/update a record and want the records value selected) you would specify this in $selected_value.
You also need to DEFINE (SERVER_NAME, DB_USER, DB_PASSWORD, DB_NAME) in config.php which is included. This is not neccesary if you already have a Mysql connection.
Upon instantiating the SQLDropDown, you can choose to connect to Mysql using SQLDropDown(true) which will connect you to the Mysql DB (if you set everything up in config.php correctly). If you already have a current mysql connection, just use SQLDropDown(false).
There's obviously room for improvement. Like adding CSS to the drop down. However, it functions as I need it to. Hopefully it will be useful to others.
Please Email me with Questions / Comments / Suggestions ETC. And please be nice, this is my first upload.
Mike Condiff
mcondiff@gmail.com |