i have a table 'tbl_department' with 2 fields 'dpt_id' n 'dpt_name' i want to fetch all 'dpt_name' as listbox output on a page.
following this sample from excellent Yii documentation, i've worked out the username from tbl_user. You can get that table, using the minimal sql script protected/data/schema.mysql.sql that get installed when you create the empty application with yiic.
<?php
$records = User::model()->findAll();
$list = CHtml::listData($records, 'id', 'username');
echo CHtml::dropDownList('names', null, $list, array('empty' => '(Select a name)'));
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With