abcd abcd - 1 year ago 150
PHP Question

Php pdo display enum values in dropdown

i am trying below code to display list of enum values in select dropdown box.
but its displaying only dropdown box, but values are not displaying....

tablename = tbl_users, column name = userStatus

$stmt = $user_home->runQuery('SHOW COLUMNS FROM '.tbl_users.' WHERE field="'.userStatus.'"');
while($data = $stmt->fetch()) {
foreach(explode("','",substr($row[1],6,-2)) as $option) {

enter image description here

Note : I really tried lot before posting question here & i am new to php coding, still learning....

Answer Source

For display enum value as dropdown you can do something like this.

<?php $status = array('Y'=>'Approve','N'=>'unapprove');  ?>
<?php foreach($status as $key=>$state) { ?>
<option value="<?php echo $key;?>"><?php echo $state;?></option>
<?php } ?>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download