mySQL output of [FONT=times new roman]show columns from advertisement like 'adSection';[/FONT]
| adSection | enum('1961 Tempest Parts List','1962 Tempest/Lemans Parts List','1963 Tempest/Lemans Parts List','Pontiac (Non 61-63 Tempest/Lemans) Parts List','Non-Pontiace Car-Related Parts List','Manuals and Literature List','Memorabilia and Collectibles List','Tools, Equipment and Shop Items List','Members "Stuff for Sale" List') | | | Members "Stuff for Sale" List | |
Italics & bold added by me.
Code for the PHP fetch of the enum set:
function enum_options($table, $field) {
//Puts the values of enumerated fields in the specified tables into an array for later use.
global $default_dbname;
$link_id = db_connect($default_dbname);
$query = "SHOW COLUMNS FROM $table LIKE '$field'";
$result = mysql_query($query, $link_id);
$query_data = mysql_fetch_array($result);
if(eregi("('.*')", $query_data["Type"], $match)) {
$enum_str = ereg_replace("'", "", $match[1]);
$enum_options = explode(',', $enum_str);
return $enum_options;
}
else return 0;
}
Code for the list box population:
Call to enum_options...
$ad_section_array = enum_options('advertisement','adSection');
then...
<?php
for($i=0; $i < count($ad_section_array); $i++) {
echo "<option value = \" ".
htmlspecialchars($ad_section_array[$i]) .
" \">" . $ad_section_array[$i] . "</option>\n";
}
?>
The final code produces a list box on the page that looks like this:
...select options previous
Tools
Equipment and Shop Items List
more select options...
That's all there is. Thanks for the help.