RE: [PHP-DB] Get all the enum values from a Mysql column?
| From: | Matt Williams | Date: | Tue, 21 Nov 2000 16:51:15 +0000 |
| Subject: | RE: [PHP-DB] Get all the enum values from a Mysql column? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-4613@lists.php.net to get a copy of this message | ||
>
> Is there an easy way to get all the enum values from a column?
>
> For example I have an enum column with the values
> "Astro","Camaro","Firehawk","Neon" and I would like to
> pull those
> values out
> to put in as <option>s in a html form with <select>.
try this
obviously you need to add the <from> and <select tags> :-)
$result = mysql_query("SHOW COLUMNS FROM table_name LIKE 'enum_column'");
while ($answer = mysql_fetch_array($result))
{
ereg( "('(.*)')", $answer[1], $temp );
$array = explode( "','", $temp[2] );
while (list ($key, $val) = each ($array))
{
echo "<option value=\"$val\">$val</option>\n";
}
}
M@