On Saturday 12 January 2002 11:30, Mehmet Kamil ERISEN wrote: > Hi, > If I have en ENUM column in a mysql table, can I leverage > this through PHP to restrict user entry with a list? > Other option that I have is to create a lookup table, or > use an array.
You'll need to adapt this for your own use, but hopefully you'll get the general idea. #=========================================================== # create_list_from_ENUM #----------------------------------------------------------- # Returns array [enum vals] # # Arguments # --------- # # $dbh : a $dbh object defined in class.DBI.inc # $table : the table to get the ENUM values from # $column : the column containing the ENUM values # #=========================================================== function create_list_from_ENUM($dbh, $table, $column) { $sth = $dbh->prepare("SHOW COLUMNS FROM $table LIKE '$column'"); if ($sth) { $sth->execute(); while ($row = $sth->fetchrow_hash()) { ereg("('(.*)')", $row[1], $temp); $array = explode( "','", $temp[2] ); while (list ($key, $val) = each ($array)) { $return[] = "$val"; } } } return $return; } -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* A shortcut is the longest distance between two points. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]