The blog of galaxyAbstractor
PHP progress bar class
This class will generate HTML progress bars, while taking minimal or no resources at all on the server.
Features:
- non-GD
- Easy to use
- small (1 kb)
PHP progress bar class (8.9 KiB, 1,969 hits)
Documentation
The code should be pretty self-explainable. Here is the code from the example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
include('progress.php');
$progress = new Progress();
echo "Bar at 50% with image overlay";
$progress->percent = 50;
$progress->style = "image";
$progress->makeBar();
$progress2 = new Progress();
echo "Bar at 50% with color overlay with different border color";
$progress2->percent = 50;
$progress2->color = "#f00";
$progress2->borderColor = "#f00";
$progress2->makeBar();
$progress3 = new Progress();
echo "Bar at 50% with color overlay with different border color and different background color";
$progress3->percent = 50;
$progress3->color = "#f00";
$progress3->sColor = "#d00";
$progress3->borderColor = "#00f";
$progress3->makeBar();
$progress4 = new Progress();
echo "Bar at 100% with image overlay";
$progress4->percent = 100;
$progress4->style = "image";
$progress4->makeBar();
$progress5 = new Progress();
echo "Bar at 100% with own image overlay with different border color, 15px height";
$progress5->percent = 100;
$progress5->height = 15;
$progress5->style = "image";
$progress5->image = "progress.png";
$progress5->borderColor = "#f00";
$progress5->makeBar();
$progress6 = new Progress();
echo "Bar at 200% with image overlay, 10 px height, 150px width";
$progress6->percent = 200;
$progress6->width = 150;
$progress6->height = 10;
$progress6->style = "image";
$progress6->makeBar();
$progress7 = new Progress();
echo "Bar at 150% with image overlay, 10 px height, 150px width, no percentage showing";
$progress7->percent = 150;
$progress7->showPercent = false;
$progress7->width = 150;
$progress7->height = 10;
$progress7->style = "image";
$progress7->makeBar();
?>
</body>
</html>
List of arguments:
include('progress.php'); // include the class
$progress = new Progress(); // make a new object
$progress->percent = 50; // This would set the percent to 50%
$progress->width = "200"; // Set the width
$progress->height = "20"; // Set the height
$progress->color = "transparent"; // Background color
$progress->sColor = "transparent"; // Secondary background color
$progress->borderColor = "#000"; // Set the border color
$progress->image = "pbar-ani.gif"; // Set the image if style = image
$progress->showPercent = true; // shows the percentage
$progress->style = "image"; // This sets the style to an image. Leave empty for no image
$progress->makeBar(); // Make the bar
Recent Comments