How to create a Star(symbol) for a five star rating from a value already stored in SQL database

Good day

If anyone can assist. ive checked lots of turorials but cant seem to find something to help me.

i have a value stored in my database (value between 1 -5) i just need to know how i can create a 5 star rate using PHP CSS to show 3 stars if the value is 3 or 5 if the value stored is 5.

i have already calculated the average etc of the value in the database just need to show it as a Star

echo str_repeat('★', 3);

Thanks Chorn

so simple cant believe it, just one question can i style it in CSS to change the colour and size ?

Is it also possible to have a Half star rating IE… 2.5 shown because my average might be 2.34 etc

Sure.

As it’s just text you can use CSS color as regular. You can also try fiddling around with the width of the surrounding element and use overflow:hidden.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.