On Wed, 14 Mar 2001 12:12:22 -0800, Dennis Gearon ([EMAIL PROTECTED])
wrote:
>I'd like to see mysql_fetch_field() return as the last value in the
>object, the allowable values for an enum field as an array. Could I
>get
>a cc as well as a listserver group answer from the PHP guys as to
>whether they think this is a good idea?
>
>Is there any other EASY way to get that information about a field?
>
>It would make making <select> inputs a lot easier and more tied to
>the
>database without thinking by the programmer, and would track design
>changes to the database.

you can do something like this:

$result=mysql_query("describe $table");
while($row=mysql_fetch_array($result)){
        if($row["Field"]==$fieldname){
                $enum=$row["Type"];
                break;
        }
}

$enum will look something like:
"enum('Yes','No')"
then you parse out $enum to get the values.
put it in a function called get_enum_values($table,$fieldname) and
youre all set.

maybe there's an easier way but I don't know of it.


--
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]

Reply via email to