...

View Full Version : how to show stars , rating in php



o0O0o.o0O0o
05-01-2009, 01:44 AM
HI ,

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.

mlseim
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";
echo"
<img src='$star' alt='rated $s stars' title='rated $s stars' />
";

AlexV
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="">');



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum