RE: [PHP] GETTING ENUM FIELD VALUES

From: Date: Tue, 10 Oct 2000 12:28:12 +0000
Subject: RE: [PHP] GETTING ENUM FIELD VALUES
Groups: php.general 
Request: Send a blank email to php-general+get-19318@lists.php.net to get a copy of this message
Here is a function I use to create a drop down list of enum values: function EnumSelector($SelectName, $Table, $FieldName, $Selected=0, $Size=1) { global $DatabaseLink; $Query = "DESCRIBE $Table"; $DatabaseResult = mysql_query($Query, $DatabaseLink); while (List($Field,$Type,$Null,$RecordKey,$Default,$Extra) = mysql_fetch_row($DatabaseResult)) { If ($Field == $FieldName) { $String = substr($Type,5,count($String)-6); $String = str_replace("'","",$String); $EnumValues = explode(",",$String); } } print("<select name=\"$SelectName\" size=\"" . intval($Size) . "\">\n"); print("<option"); if (!$Selected) { print(" selected>"); } else { print(">"); } print("Select Product Type\n"); while (List($Key, $Enum) = each($EnumValues)) { print("<option"); if ($Enum == $Selected) { print(" selected>"); } else { print(">"); } print( ucwords($Enum) . "\n"); } print("</select>"); } Let me know if you have any questions. Kathleen ::-----Original Message----- ::From: LAST JEDI [mailto:jedicouncil@lastjedi.org] ::Sent: Monday, October 09, 2000 5:17 PM ::To: php-general@lists.php.net ::Subject: [PHP] GETTING ENUM FIELD VALUES :: :: ::Is there a way that you can get the values of an ENUM field using a PHP ::query? :: :: ::For example, I have a table with a column called approved, it has ::an enum of ::approved, wating approved, and not approved. Is there a way I can ::dynamically get there enum values? :: ::Thanks :: ::-- ::---------- ::Greetings Jedi - http://lastjedi.org

« previous php.general (#19318) next »