The PHP Rating System

Asked

Viewed 144 times

0

Well I’m creating a simple rating system. What I intend is that every 2 ratings he add a Star, with a maximum of 5 stars.

How do I do that? I’ve been doing this but, no kidding..

$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 just that, I add 1 star to every 1 review... Did I make the right code?

1 answer

0

add a field in DB to store the amount of votes, then at the time of receiving make a formatting (quantity / 2), if the quantity is = 5 blocks to not vote more, if not, creates the form, link, sla, to be able to vote and save in bd

Browser other questions tagged

You are not signed in. Login or sign up in order to post.