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;