Not a Member Yet,
Click here to Register

ID: 125
Viewed: 6162
Added: Apr 27, 2002
Version:
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

<!---Head--->
none

<!---Body--->


 <?
/*
// outline of table.
CREATE TABLE counter (
id INT(5) NOT NULL,
count INT(11) NOT NULL,
PRIMARY KEY (id)
);

*/
header("content-Type: image/png");
// the number of digits to display in the graphic.
$NB_DIGITS = 3;
// connection to your database
mysql_connect ("localhost","use\r\name","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
ImageString($img,5,1,0,$number,$text_color);
ImagePng($img);
ImageDestroy($img);
?>


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 - 2024 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!