<?php
//this needs to reside in its own php page
//you can include that php page in your html as you would an image:
//<IMG SRC="ratingpng.php?rating=25.2" border="0">
function drawRating($rating)
{
$imgwidth = 102;
$imgheight= 10;
$image = imagecreate ($imgwidth,$imgheight);
$back = ImageColorAllocate ($image,255,255,255);
$border = ImageColorAllocate ($image,0,0,0);
$red = ImageColorAllocate ($image,255,60,75);
//$fill = ImageColorAllocate ($image,44,81,150);
$fill = ImageColorAllocate ($image,167,216,152);
ImageFilledRectangle ($image,0,0,101,9,$back);
ImageFilledRectangle ($image,1,1,$rating,9,$fill);
ImageRectangle ($image,0,0,101,9,$border);
imagePNG ($image);
imagedestroy ($image);
}
Header("Content-type: image/png");
drawRating($_REQUEST['rating']);
?>