Re: Displaying enum field values

From: Date: Tue, 23 May 2000 15:11:59 +0000
Subject: Re: Displaying enum field values
Groups: php.general 
Request: Send a blank email to php-general+get-361@lists.php.net to get a copy of this message
>If I wanted to display the field values for an ENUM type field in a >form, how would I do this? Is there a tutorial somewhere showing how >it is to be done? Oi! I use something like this: $sql = "SHOW FIELDS FROM $table"; $res = mysql_query($sql); for($i = 0; $i < count($res); $i++) { if($res[$i]['Field'] == $field) break; } $enum = str_replace("enum(", "", $res[$i]['Type']); $enum = ereg_replace("\)$", "", $enum); $enum = str_replace("'", "", $enum); $enum = explode(",", $enum); echo "<SELECT name=$name>"; for($i = 0; $i < count($enum); $j++) echo '<OPTION value="'.$enum[$j].'">'.$enum[$j]; echo '</SELECT>'; I hope this help, Fernando Silva

« previous php.general (#361) next »