I've created a rating star system that allows user to rate 1-5. How do I change the numbers 1-5 to stars?
These are the codes below that show the numbers for the user to rate.
<?php foreach(range(1,5)as $rating):?>
<a href="rate.php?article= <?php echo $article->id; ?> &rating= <?php echo $rating ; ?> ">
<?php echo $rating; ?> </a>
<?php endforeach;?>
Are there any ways I can convert them to an image or do I have to redo my code?
Yeah for sure.
<?php foreach(range(1,5)as $rating):?>
<a href="rate.php?article= <?php echo $article->id; ?> &rating= <?php echo $rating ; ?> ">
<?php echo '<img src="images/rating_'.$rating.'.png">'; ?> </a>
<?php endforeach;?>
Now simply create the folder images and insert rating_1.png, rating_2.png and so on.
BTW: Maybe it is easier and better for you when you use it in this way (only to show):
<?php
$bla = $article->id;
foreach(range(1,5)as $rating){
echo('
<a href="rate.php?article='.$bla.'&rating='.$rating.'">
<img src="images/rating_'.$rating.'.png">
</a>
');
}
?>