Quote:
Originally Posted by Atli
Isn't that what you wanted? To get the enum values like that?
Anyways, we can't do much unless you show us the code, and perhaps an example of the output you are getting, and the output you actually wanted.
yeah i wanted the same but output is getting displayed along with the quotes like 'gsm' instead of gsm !!!
-
function getEnumFieldValues($tableName, $fieldName){
-
$field_query = mysql_query("show columns from $tableName where Field='$fieldName'");
-
if(mysql_num_rows($field_query) <= 0) return false;
-
$fieldDetail = mysql_fetch_array($field_query);
-
$type = preg_replace('/(^set\()|(^enum\()/i', '', $fieldDetail['Type']);
-
$enumFields = substr($type, 0, -1);
-
$fieldSplit = split(',', $enumFields);
-
return $fieldSplit;
-
}
-
-
-
-
$enumFields = getEnumFieldValues('agree', 'test');
-
echo '<select name="agree">';
-
foreach($enumFields as $value){
-
echo '<option value="' . $value . '">' . $value . '</option>';
-
}
-
echo '</select>';