note 30827 added to function.mysql-query
| From: | gmalcolmSPAM at BADprofessionalcredit dot com | Date: | Mon, 31 Mar 2003 19:36:31 +0000 |
| Subject: | note 30827 added to function.mysql-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46020@lists.php.net to get a copy of this message | ||
An addition to the useful post on converting enums to select by claude_minette. This function
returns an array for all possible values of a mysql enum field. I needed this to separate display
from content.
//presumes db connection
function listEnum($dbtable, $fieldname){
$describe = mysql_fetch_assoc("describe $dbtable");
while ($line=mysql_fetch_assoc($describe)){
extract($line);
if($Type != "enum" and $Field != $fieldname){continue;}
preg_match_all("/'(\w+)'/",$Type,$choices);
break;
}
//return only individual matches
return $choices[1];
}
--
http://www.php.net/manual/en/function.mysql-query.php
http://master.php.net/manage/user-notes.php?action=edit+30827
http://master.php.net/manage/user-notes.php?action=delete+30827
http://master.php.net/manage/user-notes.php?action=reject+30827