if($selected_table != NULL)
{
$execute = mysql_query("SELECT * FROM $selected_table", $conn) or die (mysql_error());
$number_of_fields = mysql_num_fields($execute);
$field_list = mysql_list_fields($jaxeed, $selected_table, $conn);
$columns = mysql_num_fields($field_list);
for ($i = 0; $i < $columns; $i++){
$fieldtypetest = mysql_field_type($field_list, $i);
$fieldlengthtest = mysql_field_len($field_list, $i);
$fieldflagtest = explode (" ", mysql_field_flags($field_list, $i));
if(in_array("enum", $fieldflagtest))
{
$render_insert .= "<tr><td bgcolor=\"#B0BADA\"><div align=right class=\"text\">" .mysql_field_name($field_list, $i). ":</div></td>";
$render_insert .= "<td bgcolor=\"#B0BADA\"><select name=" .mysql_field_name($field_list, $i). "><option>NULL</option>";
$enum_field = mysql_field_name($field_list, $i);
$select_command = mysql_query("SELECT $enum_field FROM $selected_table", $conn) or die (mysql_error());
$fetch_enum_array = mysql_fetch_row($select_command);
$enumarray = explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$fetch_enum_array));
foreach ($enumarray as $enumvalue)
{
$render_insert .= "<option>$enumvalue</option>";
}
$render_insert .= "</select></td></tr>";
}
}
This is my second try. As I understood it $enumarray should become an array containing all the different enum values, if the column is recongised to have an enum flag. Thereby the "foreach" loop should break the array down and for each look put one value as $enumvalue that would thereby become another "option" in the "select" form.
Unfortunately the only option visable in the form is the NULL and an option saying "Array". I've added the NULL cause an enum can either be NULL or one of the values.
If my code is completely wack, and this should be solved in a totally different way, please tell me. I'm only interested in the script finding out if a column is enum or not, and then list the values as options in a select form. I thank anyone who can give me some input on this.