abcd abcd - 6 months ago 73
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....


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 } ?>