Populating form item from SQL enum set Rev#2

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Duderino82

    #1

    Populating form item from SQL enum set Rev#2

    $sql = "SHOW COLUMNS FROM table LIKE 'subject' ";
    $qry = mysql_query($sq l) or die("Query not valid: " . mysql_error());
    $res = mysql_fetch_obj ect($qry);
    // This returns a row with a field 'Type' containing 'enum(...)'

    $res->Type = str_replace('en um(\'', '', $res->Type);
    $res->Type = str_replace('\' )', '', $res->Type);
    //now the string is something like this: one','two','thr ee

    $temp = explode('\',\'' ,$res->Type);
    //temp is an array with as much elements as the enum

    while ($temp)
    print array_pop($temp );



    This way is much more easier using the elements since they are elements
    of an array. Cleaver isn't it?

Working...