Q:

How to display multiple star rating in yii?

I am working on CStar rating widget in yii. I have done as follows: 
$review = Reviews::model()->findAll();
        foreach($review as $review)
        {
           $rate=$review['rating'];
           $this->widget('CStarRating',array(
                'name'=>'rating',
                'minRating'=>1,
                'maxRating'=>5,
                'starCount'=>5,
                'value'=>$rate,
                'readOnly'=>true,
            ));
            echo "<br/>";
            echo $review['title'];
            echo "<br/>";
            echo "<font color='brown'>".ucfirst($review['name'])."</font><br/>";
            echo $review['body'];
            echo "<hr/><br/>";
        }
    ?>

When I enter one review in the database, then it is ok but as I add a 2nd review, then both the review stars get mixed.
What should I do in this case?

A:

You are using the 'name' attribute of the widget, so the javascript is getting confused as there will be more than 1 input with the same name, what you have to do is use the 'model' and 'attribute' options for the widget
 $this->widget('CStarRating',array(
                'attribute'=>'rating', //change to the attribute in your model
                'model'=>$review,
                'minRating'=>1,
                'maxRating'=>5,
                'starCount'=>5,
                'value'=>$rate,
                'readOnly'=>true,
            ));

Also you need to rename the variables in your foreach, from:
$review = Reviews::model()->findAll();
foreach($review as $review)

to
$reviews = Reviews::model()->findAll();
foreach($reviews as $review)

