php - Yii - How to retrieve data from db -
how retrieve info database , show info in view (show in selection box)
i tried doesn't work
in controller:
public function actiongetgamescategory(){ $descr_en = games_type::model()->findall('descr_en'); $this->render('app_submission',array('descr_en'=>$descr_en)); }
and this
$gamescategory = yii::app()->db->createcommand() ->select('id, descr_en') ->from('games_type') ->queryrow();
in php:
<select> <option><?php echo $descr_en; ?></option> </select>
why don't utilize yii dropdownlist?
a illustration can found here.
update
i tried write solution you, i`m not sure if right data.
echo chtml::dropdownlist('gametype', "", chtml::listdata(games_type::model()->findall(), 'id', 'descr_en'), array('empty' => 'select value','id' => "gametype", 'class' => "input"));
php yii
No comments:
Post a Comment