Well, maybe this isn't what you want.... but if you don't mind a continuous bar, made of one stretched graphic, then this should work. Make a gif/jpg a few pixels wide, and a a few pixels high. It's what I use, after I find the percentage:
<?php
$imgwidth=$per_cent;
//want a longer image? do this:
$imgwidth=$per_cent*3;
<img src='Meter.jpg' width='$imgwidth' heigh='10' alt='$percent%'/>
?>
As far as repeating a small (maybe 2w by 10h) rectangular graphic, say, one for every percentile, that should be easy too. Once you have your percentage, use something like this (caution, quasi-pseudo-code 😉):
$numOfBlocks = round($per_cent); //assuming you didn't already round it
- use a for loop to echo the <img> until you reach $numOfBlocks.
- Maintain the same width and height every time you echo it. So, at 75%, you'll have 75 blocks. If you want it scaled down, use $imgwidth = $per_cent/2 or whatever is appropriate.
Hope that helped. :p I'm a newbie at answering questions 😉
edit: added a link and so on