How can I get all enum values of field SMTH?

How can I get all enum values of field SMTH?

am 02.05.2006 14:55:16 von talthen.z-serwera.o2

Hello,
How can I get all enum values of field SMTH? Do I have to use "SHOW CREATE
TABLE" and parse the results? Is there a easier way?

Regards,
Talthen

Re: How can I get all enum values of field SMTH?

am 10.05.2006 14:03:49 von totalstranger

On or about 5/2/2006 8:55 AM, it came to pass that
talthen.z-serwera.o2@nospam.pl wrote:
> Hello,
> How can I get all enum values of field SMTH? Do I have to use "SHOW CREATE
> TABLE" and parse the results? Is there a easier way?
>
> Regards,
> Talthen

This code builds either a HTML dropdown or check box from an enum or
set. May not be what you want but should give you an idea of what to do.

function
DrawFromDB($table,$field,$type,$data="",$sort="yes",$title=" ",$mult="")
{
//connect to DB;
$query=mysql_query("SHOW COLUMNS FROM ".$table." LIKE
'".$field."'") or die (mysql_error());
if(mysql_num_rows($query)>0)
{
$row=mysql_fetch_row($query);

$options=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/ ","\\2",$row[1]));
if ($sort =="yes")
sort ($options);
$ARay = explode(",",$data);
}
switch ($type)
{
case "select":
$text="\n\n\n\n";
break;

default:
$text="\n";
for ($i=0;$i {
$checked=NULL;
for ($j=0;$j {
if ($ARay[$j] == $options[$i])
$checked=" CHECKED ";
}
$text.=" VALUE='". $options[$i] . "'>".ucfirst($options[$i])." \n";
}
$text.="\n";
break;
}
return $text;
}
?>

Re: How can I get all enum values of field SMTH?

am 10.05.2006 19:23:36 von talthen.z-serwera.o2

"totalstranger"
> DrawFromDB($table,$field,$type,$data="",$sort="yes",$title=" ",$mult="")
> {
> //connect to DB;
> $query=mysql_query("SHOW COLUMNS FROM ".$table." LIKE

Ok, thanks. I thought there will be easier way...

Regards,
Talthen