Get Data Using User Id

hi guy i have problem i need get list of data when select user_id…i mean when i select user id 1 i need get all data field related with user id 1…

i attach my controll file for this

now i struck in this problem …i,m newer in yii yet give me solution

can u describe how implement control & view file for this

here is my DB & controll file

CREATE TABLE IF NOT EXISTS offer_company (

id int(60) NOT NULL AUTO_INCREMENT,

company_name varchar(150) NOT NULL,

contact_detail text NOT NULL,

User_id int(10) NOT NULL,

created varchar(60) NOT NULL,

modified varchar(60) NOT NULL,

Active varchar(25) NOT NULL,

PRIMARY KEY (id),

KEY User_id (User_id)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=39 ;

you can try this




$model=$this->loadModel($id, 'Offer Company');

$modelAdminUser=$this->loadModel($model->user_id, 'Users');

i need get this on index page

how implement for actionindex

public function actionIndex()

{


	// renders the view file 'protected/views/site/index.php'


	// using the default layout 'protected/views/layouts/main.php'


	 





				 


		$dataProvider=new CActiveDataProvider( 'OfferDetail');


		


	$this->render('index',array(


		'dataProvider'=>$dataProvider,


	));


}

index.php

<?php $this->widget(‘zii.widgets.CListView’, array(

'dataProvider'=&gt;&#036;dataProvider,


'itemView'=&gt;'_view',

)); ?>

you can write a join query and fetch the user_id redcord pass this array on dataProvider

When you pass user_id to the controller?

The controller action like this




public function actionIndex()

        {

              if(isset($_GET['user_id']))

              $uid=$_GET['user_id']

              $criteria = new CDbCriteria();

              $criteria->condition=("user_id= $uid ");

              $data=new CActiveDataProvider('OfferCompany',array('criteria'=>$criteria,'pagination'=>array('pageSize'=>10)));

              $this->render('index', array(

                        'ModelInstance' => OfferCompany::model()->findAll($criteria),

                        'dataProvider'=>$data

        }



i modify code like this & attch in octionindex that working thank you very much

public function actionIndex()

{


	      &#036;uid=Yii::app()-&gt;user-&gt;id;


          if(isset(&#036;_GET['user_id']))			 


          &#036;uid=&#036;_GET['user_id'];


          &#036;criteria = new CDbCriteria();


          &#036;criteria-&gt;condition=(&quot;user_id= &#036;uid &quot;);


          &#036;dataProvider=new CActiveDataProvider('OfferDetail',array('criteria'=&gt;&#036;criteria,'pagination'=&gt;array('pageSize'=&gt;10)));


          &#036;this-&gt;render('index', array(


                    'ModelInstance' =&gt; OfferCompany::model()-&gt;findAll(&#036;criteria),


                    'dataProvider'=&gt;&#036;dataProvider,


   	


	));


}