Star Rating

Hi guys, i’m currently creating an application with the star rating widget.

What i’m looking to achieve is that a person should only be allowed to have one rate of a product, but he may update his rating if he chooses. Therefore the system should check if a rating of that user on that product already exist. If i does, the default value of the stars should be the rating he/she submitted last time, and if the user chooses to submit again, this row in the database table should be updated. If no rating on that product has been done by this user before, he/she should be see empty stars, and if any rating is submitted this would create a new row in the database table.

I have some ideas on how some of this would be made, but i can be wrong about the method. I’m particular unsure of how the application should check wether the user already have a rating on that product.

Can you guys please help me?

I think there is a rating extension somewhere in the extension - have you checked that out?

Dear Dream

To do that you need to follow those steps :

1- add table to save rating action

for example

id - user_id - post_id - date - rate

rate( rate value )

2- when user will rate some post for example data will save in above table .

3- if user will change him rate then you need to check your table :

a- if user had no raw in table insert new one if else go to (B)

b- call function to return user data where post = current post and user_id= $user_id

c- if old rate != new $rate then update record with new value

That is :)

rate action will be like that :

 public function actionRate(){


 	/// note user id you can get it from session or any method u saved it befor 


 	if(isset($_GET['post_id']))   {





 	$model=rate::model()->find("user_id=$user_id and post_id=$post_id"); 


 	if($model===null){/// So no old recorde 


    	//// insert new value in table 





  	if($old_rate!== $new_rate)  {













Hello, this extension perhaps ?

Hey guys, thanks for answering.

Samilo’s answer was the one i was looking for, and thank you very much for that.

I’ve already looked at the extension Putera is referring to, but it can’t do some of what i want.

So again, thanks for helping me out on this :)

plz any1 can place a complete demo of how to apply css on cstarrating??????

Please can any one help me, i am new user to yii, i am doing star rating

ex:giving user to rate some product so please anyone provide detail steps.

Presently am using for my appliction yii farmework and yii booster

And i seached in google but all are using cstar rating so it will be conflict to yii booster…

So can anyone please guide me through this…

for best help follow this wiki -

Managing a star rating with the StarRating widget in Yii 2

and use Star Rating Yii Widget…