I must produce a combo box (eventually operating it using jQuery Ajax), that is populated using the enum values from the database table area.

Let me use later these choices to filter mysql_query results on the page.

I am thinking the easiest method to do that would be to echo the whole form and combo box using the enum values because the option tags values. Where I are unsuccessful is understanding how you can call the enum values to begin with.

For those who have a much better suggestion regarding how to do that, please tell me!


I discovered the next code, which seems to complete things i need. However, it appears to seize all of the enum arrays from the table, and convert each array right into a combo box. This is not an issue when i was wishing to produce combo boxes for each one of the separate arrays anyway. However, If only to alter an order from it. Can there be in whatever way I'm able to edit this code to manage each set? As well as get it specify which area I must echo, after which repeat as numerous occasions when i need? I understand that doing that will mean more code, and wouldn't be as efficient.

The PHP:

$describe=mysql_query("describe $table");
while ($ligne=mysql_fetch_array($describe)){
    if (substr($Type,0,4)=='enum'){
        if (sizeof($enums)>0){
            echo "<select name='enum'>\n";
            for ($i=0; $i<sizeof($enums);$i++){
                $elem=strtr($enums[$i],"'"," ");
                echo "<option value='".$elem."'>".$elem."</option>\n";
            echo "</select>";

Thought I ought to mention, the 3 fields which contain enums are imgFamily, imgClass, and imgGender. I'd like the combo boxes for the reason that order ideally.

You should use:

SELECT column_type FROM information_schema.columns WHERE table_name = :myTable AND column_name = :myColumn

This can return something similar to this:


For you to parse in php. However, It would possibly be superior to keep their email list in code or any other table than as enum values.