I've got a Form I'm building, and would like the drop down boxes to contain
the values for one of the fields of type "enum" (not from the actual records
in the DB, but the definition of the enum field in MySQL)
For example: A field called "userlevel" with enum types "admin" and
I would like to run a query to get the values "admin" and "visitor" (and any
other enum value types) to use in a drop down list on a form.
Here's what I've found so far (seems pretty bulky):
If you run a query of "SHOW COLUMNS FROM tablename" it gives the returned
value of "enum('admin', 'visitor')" in the second column (column called
A snippet of code we found in PHPMyAdmin gives this little routine:
$enum = str_replace('enum(', '', $row_table_def['Type']);
$enum = ereg_replace('\\)$', '', $enum);
$enum = explode('\',\'', substr($enum, 1, -1));
$enum_cnt = count($enum);
Which apparantly takes the result from the "SHOW COLUMNS..." query and
strips out the values.
Is this the easiest way to do this using PHP and MySQL?
Any help is greatly appreciated - thank you!
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php