rank bar display

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ijlal2
Forum Newbie
Posts: 6
Joined: Sun Jul 06, 2008 2:06 pm

rank bar display

Post by ijlal2 »

hi all

i need your help. I am making a ranking system. I have calculated the ranks of all the products out of 10.... like 7 out of 10.. and 5 out of 10.. these ranks are stored in database.

now i want a graphical statistics horizontal bar showing the rank of product along with the prodcut name.
like

Product 1 Graphic BAR showing 7 stars or else out of 10 stars.
Product 2 Graphic BAR showing 4 stars or else out of 10 stars.

similarly like that.. basically i am confused how to display GRAPHIC rank bar for products.
Please Help.
regards
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: rank bar display

Post by jaoudestudios »

There are a few ways of doing it. (I will take 5 stars to be the max for the examples)

It depends on how accurate you want the stars to be. i.e 1/5, 2/5, 3/5 etc or 1.5/5.

I would keep it simple with integers and forget half stars etc.

The easiest way would be to have different images for each, so an image that has 1/5 stars and 2/5 etc up to 5/5.

Then display the relevant image.

For the future if you wish to do part stars you could set the 5 star image as a background image in CSS and change the CSS width of that div using PHP, so only part of the 5 star image is displayed. (and it could be 3.6 out of 5)
Post Reply