View Full Version : how to show stars , rating in php
05-01-2009, 01:44 AM
I want to show the rating stars in the column. Is there any easy way to do that in php. I have 1-5 levels stored in databse.
05-01-2009, 03:21 AM
I would do it this way ...
Create 5 different .gif images, representing the 5 stars.
Name them like ... star1.gif, star2.gif, star3.gif, star4.gif, star5.gif
Then, display the correct one based off the value in the database.
$s = 4;
$star = "star".$s.".gif";
<img src='$star' alt='rated $s stars' title='rated $s stars' />
05-01-2009, 05:09 PM
Or you can also only have one star image that is repeated (the number stored in the DB must be the number or stars)...
for ($i = 0; $i < $starsCount; $i++) //$starsCount is a DB value
echo('<img src="/images/star.png" alt="*" title="">');
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.