Php: How to show star rating

## Showing Rating in Php using star & blank rating


$ProductId = 1;

$product_rating_qu = mysql_query("select avg(rating) as star_rate from ratings where ratedto='" . $ProductId . "'");
$product_rating_found   = mysql_num_rows($product_rating_qu);


$star_rate = 0;
if($product_rating_found)
{
    $product_rating_res = mysql_fetch_array($product_rating_qu); 
    //print_r($product_rating_res);

    $star_rate = $product_rating_res['star_rate'];
    for($rcnt=0; $rcnt<$star_rate; $rcnt++)
    {
        echo "<span class='rated-star'>&#x02605;</span>";
    }
    $star_rate = $rcnt;
}

for($star_blank=0; $star_blank < (5-$star_rate); $star_blank++)
{
    echo "<span class='unrated-star'>&#9734;</span>";
}

// star Rating ends here
?>
Please follow and like us:
0