Re: how to recognize ENUM column in table?
| From: | Afan Pasalic | Date: | Fri, 07 Dec 2007 13:49:46 +0000 |
| Subject: | Re: how to recognize ENUM column in table? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265562@lists.php.net to get a copy of this message | ||
Jim Lucas wrote:
Afan Pasalic wrote:Thanks Jim. But, I was actually looking for column type is like ENUM, with some differences. And it's SET type. -afanhi, I use the code from http://www.php.net/manual/en/function.mysql-fetch-field (example #1) I'm getting everything I need but can't recognize if the column is ENUM() type? e.g. column "status" is ENUM('0','1') or ENUM('live','hidden','archive') or something like that. I want to recognize this column and then create a form with radio buttons o 0 o 1 or o live o hidden o archive is it possible? thanks. -afanTry something like this. my table structure was CREATE TABLEcmsws_com.examples(col1ENUM( '0', '1' ) NOT NULL ,col2ENUM( 'one', 'two', 'three' ) NOT NULL ) ENGINE = MYISAM <?php # setup your db connection and stuff... $result = mysql_query("SHOW COLUMNS FROM examples"); if (!$result) {echo 'Could not run query: ' . mysql_error(); exit;} if (mysql_num_rows($result) > 0) {while ($row = mysql_fetch_assoc($result)) { print_r($row); }} My results were Array ([Field] => col1 [Type] => enum('0','1') [Null] => NO [Key] => [Default] => [Extra] =>) Array ([Field] => col2 [Type] => enum('one','two','three') [Null] => NO [Key] => [Default] => [Extra] =>) Hope this fits the bill