RE: [PHP-DB] Populating a dropdown list with ENUM values...
Thanks to everyone who responded. I have found a function that fills the role perfectly. -Original Message- From: Russ [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 26, 2002 7:47 PM To: NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED] Subject: RE: [PHP-DB] Populating a dropdown list with ENUM values... G'day Scott: I wrote this function to do just what you're atfer: You may need to mess with it for you're own needs - but go for your life! //function: "enum_select()" - automatically generate an HTML select menu from a MySQL ENUM field //1). takes a table name: '$table' //2). a name for the menu '$name' //3). a CSS class function enum_select($table,$name,$class) { $sql = "SHOW COLUMNS FROM $table"; $result = mysql_query($sql); $select = "\n\t"; while($myrow = mysql_fetch_row($result)){ $enum_field = substr($myrow[1],0,4); if($enum_field == "enum"){ global $enum_field; $enums = substr($myrow[1],5,-1); $enums = ereg_replace("'","",$enums); $enums = explode(",",$enums); foreach($enums as $val) { $select .= "$val\n\t"; }//end foreach }//end if }//end while $select .= "\r"; return $select; }//end function All the best. Russ -Original Message- From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 3:38 AM To: '[EMAIL PROTECTED]' Subject: [PHP-DB] Populating a dropdown list with ENUM values... I am working on an application that has several different fields that are populated dropdown lists. In every case, this data is simply data from a MySQL table column and works great. I have run into a new difficulty though... One field that I am wanting to populate in a dropdown list is an ENUM field. I am trying to figure out how to do this. I have seen a couple ideas in the newsgroups, but most are pretty complex and about a year or so old. I am hoping for a simpler solution that may have been developed since these posts. Thanks in advance. Scott Nipp Phone: (214) 858-1289 E-mail: [EMAIL PROTECTED] Web: http:\\ldsa.sbcld.sbc.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Populating a dropdown list with ENUM values...
G'day Scott: I wrote this function to do just what you're atfer: You may need to mess with it for you're own needs - but go for your life! //function: "enum_select()" - automatically generate an HTML select menu from a MySQL ENUM field //1). takes a table name: '$table' //2). a name for the menu '$name' //3). a CSS class function enum_select($table,$name,$class) { $sql = "SHOW COLUMNS FROM $table"; $result = mysql_query($sql); $select = "\n\t"; while($myrow = mysql_fetch_row($result)){ $enum_field = substr($myrow[1],0,4); if($enum_field == "enum"){ global $enum_field; $enums = substr($myrow[1],5,-1); $enums = ereg_replace("'","",$enums); $enums = explode(",",$enums); foreach($enums as $val) { $select .= "$val\n\t"; }//end foreach }//end if }//end while $select .= "\r"; return $select; }//end function All the best. Russ -Original Message- From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 3:38 AM To: '[EMAIL PROTECTED]' Subject: [PHP-DB] Populating a dropdown list with ENUM values... I am working on an application that has several different fields that are populated dropdown lists. In every case, this data is simply data from a MySQL table column and works great. I have run into a new difficulty though... One field that I am wanting to populate in a dropdown list is an ENUM field. I am trying to figure out how to do this. I have seen a couple ideas in the newsgroups, but most are pretty complex and about a year or so old. I am hoping for a simpler solution that may have been developed since these posts. Thanks in advance. Scott Nipp Phone: (214) 858-1289 E-mail: [EMAIL PROTECTED] Web: http:\\ldsa.sbcld.sbc.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Populating a dropdown list with ENUM values...
Did you see the very last user contributed comment at http://www.php.net/manual/en/function.mysql-fetch-field.php? It'll help you immensely. Christopher S. Cosby SciCare Software Services 770.236.1128 > -Original Message- > From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 26, 2002 3:38 PM > To: '[EMAIL PROTECTED]' > Subject: [PHP-DB] Populating a dropdown list with ENUM values... > > > I am working on an application that has several different fields > that are populated dropdown lists. In every case, this data > is simply data > from a MySQL table column and works great. I have run into a > new difficulty > though... One field that I am wanting to populate in a > dropdown list is an > ENUM field. I am trying to figure out how to do this. I > have seen a couple > ideas in the newsgroups, but most are pretty complex and > about a year or so > old. I am hoping for a simpler solution that may have been > developed since > these posts. Thanks in advance. > > Scott Nipp > Phone: (214) 858-1289 > E-mail: [EMAIL PROTECTED] > Web: http:\\ldsa.sbcld.sbc.com > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > - - - - - - - Appended by Scientific-Atlanta, Inc. - - - - - - - This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.