PHP Rating System

0

Well I'm creating a simple rating system. What I intend is that every 2 ratings it adds a Star, with a maximum of 5 stars.

How do I do this? I've been doing this more, no geito ..

$star = "<li><a href='#'><i class='fa fa-star' aria-hidden='true'></i></a></li>";
$max_stars = 5;
$total_stars = $product_review / $max_stars * 1;

 for($i=1;$i<=5;$i++) {

  if($product_review >= $i) {

    if($total_stars) {

       echo $star; 
  }

  }
 }

And so, I created this but ... I'm 100% confused .. because it does exactly that, so add 1 star to every 1 review ... Did I make the code right?

    
asked by anonymous 02.11.2017 / 16:49

1 answer

0

add a field in the DB to store the number of votes, then at the time of receiving it makes a formatting (quantity / 2), if the quantity is = 5 blocks not to vote for more, sla, to be able to vote and save on bd

    
02.11.2017 / 16:52