in my database ı have numbers 1
, 2
, 2.5
, 3
, 3.5
, 4
, 4.5
and 5
I want to convert these numbers to stars.
I have a full star and a half star.
How ı can do that after getting information from database?
I have the rating tag on the database.
<?php
for($x=1;$x<=$starNumber;$x++) {
echo '<img src="path/to/star.png" />';
}
if (strpos($starNumber,'.')) {
echo '<img src="path/to/half/star.png" />';
$x++;
}
while ($x<=5) {
echo '<img src="path/to/blank/star.png" />';
$x++;
}
?>
*Assuming you are using PHP
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With