'; $rating_query = "SELECT ROUND(AVG(rating),1) AS avg_rating, COUNT(*) AS count FROM reviews WHERE product_id='$p_id'"; $run_query = mysqli_query($con,$rating_query); $row = mysqli_fetch_array($run_query); $r_count = $row['count']; if($row > 0){ $avg_count=$row["avg_rating"]; echo '
'.$avg_count.'
'; $i=1; while($i <= round($avg_count)){ $i++; echo' '; } $i=1; while($i <= 5-round($avg_count)){ $i++; echo' '; } echo'
'; } echo'
'; if ($r_count > 0){ echo''; }else{ echo'

no Reviews yet be the first person to rate the product

'; } echo'
'; } if(isset($_POST["rating_reviews"])){ $p_id = $_POST["proId"]; $rating_query = "SELECT ROUND(AVG(rating),1) AS avg_rating, COUNT(*) AS count FROM reviews WHERE product_id='$p_id'"; $run_query = mysqli_query($con,$rating_query); $row = mysqli_fetch_array($run_query); $r_count = $row['count']; if($row > 0){ $avg_count=$row["avg_rating"]; echo '
'; $i=1; while($i <= round($avg_count)){ $i++; echo' '; } $i=1; while($i <= 5-round($avg_count)){ $i++; echo' '; } echo'
'.$r_count.' Review(s) | Add your review '; } } ?>