PHP Vanilla Implementation:
<select> <? $result = mysql_query('SHOW COLUMNS FROM '.$table_name.' WHERE field="'.$column_name.'"'); while ($row = mysql_fetch_row($result)) { foreach(explode("','",substr($row[1],6,-2)) as $option) { print("<option>$option</option>"); } } ?> <select>
PHP Data Object Implementation
<select> <? $sql = 'SHOW COLUMNS FROM '.$table_name.' WHERE field="'.$column_name.'"'; $row = $db->query($sql)->fetch(PDO::FETCH_ASSOC); foreach(explode("','",substr($row['Type'],6,-2)) as $option) { print("<option>$option</option>"); } ?> </select>
source share