MySQL enum displaying values in Select
| From: | bob | Date: | Sun, 02 Jun 2002 02:58:03 +0000 |
| Subject: | MySQL enum displaying values in Select | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-19570@lists.php.net to get a copy of this message | ||
Hello,
I have a problem I can't seem to overcome. Maybe it's just something simple
but for some reason I am unable to read in values from a mysql db column
(enum) and display the results in an option box.
I can display the values to the screen but I can't seem to get them into the
option box. This is the snippet of code I've been struggling with... what am
I doing wrong? All I get in the option box is one value called 'Array' which
isn't even a value from my enum column.
Please let me know if you need more info.
Thanks for the help.
Rob.
(db connections strings here.....)
$sql = "SHOW COLUMNS FROM $table_name LIKE 'categories'";
$result = @mysql_query($sql);
$query_data = mysql_fetch_array($result);
if (eregi("('.*')", $query_data["Type"], $match)) {
$enum_str = ereg_replace("'", "", $match[1]);
$enum_options = explode(',', $enum_str);
}
array_push($enum_options, $query_data);
echo "ENUM options with the default value:<br>";
foreach($enum_options as $value) echo "$value<br>";
?>
<SELECT NAME=$categories size=5 multiple>
<SELECT NAME=member_groups[] size=5 multiple>
<option><? echo "$value"; ?></option>
</SELECT>
<?