Thread: enum

  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Rep Power
    I am fairly new to mysql. I am building a database with php as the front end.
    I have an ENUM field, something like this
    (the ratings of UK movies, in case your wondering)
    I am trying to get php to query that field and return the possible values that field can have, so i can include them in a drop down box, or something similar. Is this possible, or has anyone got any ideas on how to do this?
  2. #2
  3. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Central Florida, USA
    Rep Power
    This problem has been solved in phpMyAdmin. Why not go to
    and download the source to find out how?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Rep Power
    I think i found it...
    <select name="funcs[$field]">
    <option value="">n";
    for($j=0; $j<count($set);$j++)
    echo '<option value="'.substr($set[$j], 1, -1).'"';
    if($data == substr($set[$j], 1, -1) &#0124; &#0124; ($data == "" && substr($set[$j], 1, -1) == $row_table_def["Default"]))
    echo " selected";
    echo ">".htmlspecialchars(substr($set[$j], 1, -1))."n";
    echo "</select>

    If that is right, i am well and truely confused!
  6. #4
  7. No Profile Picture
    Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Caro, Michigan
    Rep Power
    Issue a "show columns from table" or "desc table" command through mysql_query(). It'll give you some out put like this:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    | Field | Type |
    | Select_priv | enum('N','Y') |
    | Insert_priv | enum('N','Y') |
    Treat the result just like any other result set.
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    //not tested
    $enumcolumn = $row[Type];
    $enumvalues = substr($enumcolumn,5,-1);
    $enumvalues = str_replace("'","",$enumvalues);
    $enum_array = explode(",",$enumvalues);
    Something like that will give you an array filled with the possible values of the enum.

    ---John Holmes...

    * The manual can probably answer 90% of your questions...
    * PHP Manual.
    * MySQL Manual:

Similar Threads

  1. ENUM Storage
    By philipz in forum MySQL Help
    Replies: 4
    Last Post: January 5th, 2004, 07:24 AM
  2. Force column values (enum?)
    By anded in forum MySQL Help
    Replies: 2
    Last Post: December 18th, 2003, 06:06 PM
  3. how to enter a enum value containing a comma
    By kbrentnell in forum MySQL Help
    Replies: 0
    Last Post: September 5th, 2003, 08:31 PM
  4. Replies: 3
    Last Post: December 18th, 2002, 04:48 PM
  5. ENUM question
    By spiggott in forum MySQL Help
    Replies: 1
    Last Post: August 12th, 2002, 06:36 AM

IMN logo majestic logo threadwatch logo seochat tools logo