Undefined Offset: 0

hello friend…

i have found an error…

Undefined offset: 0

here is my code.




    public function actionIndex()

	{

	$model = new ProductIndex();

	$price = (isset($_GET['ProductIndex']['price'])) ? $_GET['ProductIndex']['price'] : array();

 CVarDumper::dump($price);

     $criteria = new CDbCriteria();

$criteria->with = 'pricing'; 

	 $criteria->together = true; 

	if ( $price[0] == 1 )

	{

	$results = pricing::model()->findAll(array( 'condition'=>'price>=:price AND price <= :price1',

    'params'=>array(':price'=>0, ':price1'=>2000),));

	$values = array();

	foreach($results as $r) $values[] = $r->price;

	$criteria->addInCondition( 'pricing.price', $values ); 

	}

$dataProvider = new CActiveDataProvider('ProductIndex',

	array('criteria'=>$criteria));

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

            'dataProvider'=>$dataProvider,

			'model'=>$model,

            ));

			}

how to solve this error.please suggest me.

thanks a lot.

Try this "if" condition




   public function actionIndex()

   {

         .......

        if (isset($_GET['ProductIndex']['price']) && $price[0] == 1 )

        {

         .....  

        }

       ......  

   }



thanks mbala …

u r solve my problem very easily…

thanks a lot.