listbox

I have a query that i want to connect to a listbox…the result of query…how can i do???

Help meeee…:slight_smile:

Hi, Kitty

Could you paste in some code for an idea

This is my code




public function actionCreate()

	{

		 $model=new ruoli;

		

		if(isset($_POST['ruoli']))	

		{	

			$connection=new CDbConnection('oci:dbname=//10.0.0.227:1521/oraprod','ora02','oracle');

			$connection->active=true;

			$command=$connection->createCommand('select descrizione from ruoli where ruolo_id=ANY(select ruolo_ruolo_id from accesso_ruoli where accesso_accesso_id='.$_GET["id"].')');

			$command->execute();   

			$reader=$command->query();

			$i=0;

			 foreach($reader as $row) 

					{

						$ID[$i]= $row['DESCRIZIONE'];

						echo $ID[$i];

						$i++;

						

					}

			 

			$this->redirect(array('view','id'=>$model->RUOLO_ID));

		}







The result i want to put in a listbox…

Depending on which of the 3 list box you use:

http://www.yiiframework.com/doc/api/CHtml#listBox-detail

http://www.yiiframework.com/doc/api/CHtml#activeListBox-detail

http://www.yiiframework.com/doc/api/CActiveForm#listBox-detail




public static string [b]listBox[/b](string $name, mixed $select, array $data, array $htmlOptions=array ())



Basically that array $data is what you need to fill.

http://www.yiiframework.com/doc/api/CHtml#listData-detail

Use the function listData

The $model can be the result of your query.

Also keep in mind this is how value is set:

http://www.yiiframework.com/doc/api/CHtml#value-detail

Hope that helps.