Yes there is... make sure you are running GD that supports GIF files... and here is what I have done recently to create a button counter... (note that the button is just a piece of HTML that can be placed on any page on the web, it will reference my code, look up the account in my database and return a GIF image with the new stats to the user)...:
// $id is a GET variable passed to this file
// connect to db
include("dbcon.inc.php");
$t = mysql_query("SELECT * FROM top100 WHERE id = '$id'");
function createimage($gesamt = "N/A", $heute = "N/A"){
Header("Content-Type: image/gif");
$im = ImageCreateFromGIF("top100.gif");
$red = ImageColorAllocate($im, 255, 0, 0);
$black = ImageColorAllocate($im, 90, 90, 90);
$image_height = ImageSY($im);
$image_width = ImageSX($im);
$font_height = ImageFontHeight(1);
$font_width = ImageFontWidth(1);
$channel = "GESAMT: " . $gesamt;
$length = $font_width * strlen($channel);
$image_center_x = ($image_width/2)-($length/2);
$image_center_y = ($image_height/2)-($font_height/2);
ImageString($im, 1, $image_center_x, $image_center_y + 1, $channel, $black);
$channel = "HEUTE: " . $heute;
$length = $font_width * strlen($channel);
$image_center_x = ($image_width/2)-($length/2);
$image_center_y = ($image_height/2)-($font_height/2);
ImageString($im, 1, $image_center_x, $image_center_y + 9, $channel, $black);
ImageGIF($im);
}
if($result = mysql_fetch_array($t)){
$gesamt = $result[hosts];
$heute = $result[hoststoday];
$now = date("Y-m-d H-i-s");
$t = mysql_query("UPDATE top100 SET hits = hits + 1, lasthit = '$now' WHERE id = '$id'");
//check for hits today============
$today = date("Y-m-d") . " 00:00:00";
$t = mysql_query("SELECT id FROM top100 WHERE lasthit > '$today' AND id = '$id'");
if($temp = mysql_fetch_array($t)){
$t = mysql_query("UPDATE top100 SET hitstoday = hitstoday + 1 WHERE id = '$id'");
}else{
$t = mysql_query("UPDATE top100 SET hitstoday = 1 WHERE id = '$id'");
}
if($visitero100==$id){
} else {
$t = mysql_query("UPDATE top100 SET hosts = hosts + 1 WHERE id = '$id'");
//hosts today=======
$t = mysql_query("SELECT id FROM top100 WHERE lasthit > '$today' AND id = '$id'");
if($temp = mysql_fetch_array($t)){
$t = mysql_query("UPDATE top100 SET hoststoday = hoststoday + 1 WHERE id = '$id'");
}else{
$t = mysql_query("UPDATE top100 SET hoststoday = 1 WHERE id = '$id'");
}
// to count unique hits, block the counter for this user for 30 mins
setcookie("visitero100",$id,time()+1800);
}
$data = mysql_query("SELECT * FROM top100 WHERE id = '$id'");
$result = mysql_fetch_array($data);
$gesamt = $result[hosts];
$heute = $result[hoststoday];
createimage($gesamt, $heute);
} else {
createimage();
}
?>