search option

i have 2 tables in db. i want to search and display the details. how i will display the details… i don’t no my code is right or not… give me some suggestions. here my code is…

$criteria = new CDbCriteria();				//create new object for search function


		if(isset($_GET['q']))								//if value of search is set


			$q = $_GET['q'];								//assign search box value to variable


			//var_dump($criteria->compare('user_name', $q, true, 'OR'));exit;

			$criteria->compare('id', $q, true);					//compare model attributes to search value

			$criteria->compare('user_name', $q, true);			//compare model attributes to search value



		$model=new CActiveDataProvider("StudentTbl", array('criteria'=>$criteria));					//load the model 





Are U planing to use this for CGridView or something similar

use grid view and advanced search

you can use gridview here help yourself

tnx for reply