Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 125
Viewed: 5572
Added: Apr 27, 2002
Snippet uploaded by: snippet
Written By: snippet
Demo: Sorry, no demo

User Rated at: 5 Stars5 Stars5 Stars5 Stars5 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

This little script will get the number form a mysql table and make that number a graphic through the use of the GD Library (must have this enabled in the php.ini file). Just put this code in a file whatever.php and then in the main file just include the whatever.php file whereever you want the graphic counter to appear. This will work with jpg or png. if you want jpg make sure you change all png to JPEG



// outline of table.
CREATE TABLE counter (
count INT(11) NOT NULL,

header("content-Type: image/png");
// the number of digits to display in the graphic.
// connection to your database
mysql_connect ("localhost","username","password");
mysql_select_db ("db_name");

// gets the number from the database.
$select = mysql_query("select count from counter");
while ($row = mysql_fetch_array($select){
$number = $row["count"];

$img = ImageCreate(9 * $NB_DIGITS + 1, 17);
//the color of the background.
$bg_color = ImageColorAllocate($img, 255 ,255, 255); // Ex: black
// the color of the numbers.
$text_color = ImageColorAllocate($img, 0, 0, 0); // Ex: white

// makes the graphic

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2018 All Rights Reserved. Conditions