<?php
$business=$model->reviewBusinesses;
foreach ($business as $business) {
$c = $business->rating; ?>
<div class="ratings"> <!--use class in order to show rating horizontally -->
<?php
$this->widget('ext.DzRaty.DzRaty', array(
'name' => 'rating',
'value' => $c,
'options' => array(
'readOnly' => TRUE,
),
));
?>
</div>
<?php } ?>
I am working in yii
and using dzraty extension for star rating. In one of my view file which is userbusiness.php
of business
table which has relationship with revewbusiness
table. I am getting rating from reviewbusiness
table and showing it in one of my view file of business
as mentioned above. I am getting rating in numeric form, but from above code i can only get rating
of 1st review in star form while the rest of the rating is coming in numeric form. Can someone find my error?
like this
first_star second_star third_star fourth_star fifth_star
2
3
4
5
For those who really want to understand, in reviewbusiness
table, i am getting rating, reviews of users.
Try this (you are using business
as data set and as key at the same time):
<?php $business = $model->reviewBusinesses;
$i = 0;
foreach ($business as $business_key) {
$c = $business_key->rating;
?>
<div class="ratings"> <!--use class in order to show rating horizontally -->
<?php
$this->widget('ext.DzRaty.DzRaty', array(
'name' => 'rating_'.$i,
'value' => $c,
'options' => array(
'readOnly' => TRUE,
),
'htmlOptions' => array(
'id' => 'rating_'.$i,
),
)); ?>
</div>
<?php
$i++;
}
?>