Rating Code

openmind's picture

He has: 945 posts

Joined: Aug 2001

I am trying to develop a system using ColdFusion that produces a quick graphical view of a site's rating.

The sytem I have in place at the mo can be viewed here. If you look to the far right of each resource you will see the rating after a certain no. of votes. This doesn't look particuarly appealing, especially if a resource has not been rated yet.

The effect I would like to achive is similar to the one used at aspin.com where a graph is displayed varying in height dependant on the site rank.

I can easily get the numerical rating, i.e 9.75 after 15 votes say, but what is the easiest way to convert this to a simple gif file?

Ideally this needs to be written in CFML but I would be curious to see how it would be done in PHP. Although I don't know PHP from my elbow I should be able to adapt the code Smiling

Any ideas?

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

You may want to think about having a set of gifs..

0.00.gif, 0.25.gif, 0.50.gif, 0.75.gif,
1.00.gif, 1.25.fig, 1.50.gif, 1.75.gif
etc. etc. etc.
9.00.gif, 9.25.gif, 9.50.gif, 9.75.gif,
10.00.gif

It'a be much easier on your server to just print the percentage in an tag.

That's probably how I would do it in PHP. The other option is to use a GD library, but that takes a bit more system resources. I only use GD when I need to make graphs (rather than simple bars). An example of a PHP/GD graph:
http://digitalart.org/artwork/artwork.php?ID=139&show_graph=1
http://digitalart.org/artwork/artwork.php?ID=126&show_graph=1

Mark Hensler
If there is no answer on Google, then there is no question.

openmind's picture

He has: 945 posts

Joined: Aug 2001

Thnx Mark,

I've actually gone with the width idea where the width is the site rating Smiling

Got it sorted though!!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.