as you can see the first product is 4,5 stars rating and it apply for the rest of the product.I have function called (rateYo) its Turn numbers into stars. So I want to use this function to show star rating for all my products. but when I use it, its show the only first result to other result. for example - If the rating for the first product is four stars, it will be the same for the rest of the products. I want to make each product appear with its own rating.
I change the from ID to class for to show in foreach loop. this is my function
<script type='text/javascript'>
$(function () {
$(".ratYo").rateYo({
rating: <?php echo $list['averageRating']?>,
starWidth:"20px",
readOnly: true
});
});
</script>
and this is my code in html
<?php
foreach($pro as $list){
?>
<div style="left: -60px;position: relative; class="ratYo">
<script>
$(function () {
$(".ratYo").rateYo({
rating: <?php echo $list['averageRating']?>,
starWidth:"20px",
readOnly: true
});
}); </script>
</div>