Home Tutorial Php Phpgd PHP GD Progress Bar

 
 

Share on Google+Share on Google+
PHP GD Progress Bar
Posted on: November 7, 2009 at 12:00 AM
Advertisement
This example shows how to display progress bar in php gd.

<?php

header("Content-type: image/jpeg");

$current = isset($_GET['c']) ? $_GET['c'] : 50;

$start = isset($_GET['s']) ? $_GET['s'] : 0;

$end = isset($_GET['e']) ? $_GET['e'] : 100;

$p = isset($_GET['p']) ? $_GET['p'] : 0;

$pos = floor(2 * $current/($end - $start) * 100);

$im = imagecreate(200, 16);

$white = imagecolorallocate($im, 255, 255, 255);

$black = imagecolorallocate($im, 0, 0, 0);

$green = imagecolorallocate($im, 0, 204, 51);

imagesetthickness($im, 2);

imagerectangle($im, 0, 0, 200, 15, $white);

imagefilledrectangle($im, 0, 0, $pos, 16, $green);

if ($p) {

$text = ($pos / 2).'%';

$font ='C:/WINNT/Fonts/arial.ttf';

$black = imagecolorallocate($im, 0, 0, 0);

imagettftext($im, 8, 0, 95, 12, $black, $font, $text);

}

imagejpeg($im);

imagedestroy($im);

?>

After running the program you will get the following output

Advertisement

Related Tags for PHP GD Progress Bar:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 7, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com