CakeFest 2025 Madrid: The Official CakePHP Conference

Voting

: min(zero, eight)?
(Example: nine)

The Note You're Voting On

booga
21 years ago
a simple way of using imagerectangle to create a percentage bar

<?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) {
$image = imagecreate(102,10);
$back = ImageColorAllocate($image,255,255,255);
$border = ImageColorAllocate($image,0,0,0);
$red = ImageColorAllocate($image,255,60,75);
$fill = ImageColorAllocate($image,44,81,150);
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($rating);

?>

<< Back to user notes page

To Top