Just make a html image tag and call your image counter script from that tag!
// add to your html output page
[PHP]<img src='/my_counter.php?page=index' height='24' width='100' alt='' />[/PHP]
example counter file content
file name =
index
// my_counter.php
[PHP]<script language='php'>
/* path to counter files */
$path = './counters/';
/* default count, invalid page or no page or counter file doesn't exist */
$count = 0;
if ( ! empty ( $_GET['page'] ) )
{
$p = trim ( $_GET['page'] );
if ( preg_match ( "/^[a-z]{4,10}$/", $p ) && file_exists ( $path . $p ) )
{
$io = fopen ( $path . $p, 'r+' );
$count = fgets ( $io, 11 );
fseek ( $io, 0 );
fputs ( $io, sprintf ( '%010d', ++$count ) );
fclose ( $io );
}
}
if ( $count == 0 )
{
++$count;
}
$im = imagecreate ( 100, 24 );
$bg = imagecolorallocate ( $im, 255, 255, 255 );
$tc = imagecolorallocate ( $im, 0, 0, 255 );
imagestring ( $im, 5, 6, 4, sprintf ( '%010d', $count), $tc );
header ( 'Content-Type: image/png' );
imagepng ( $im );
imagedestroy ( $im );
</script>[/PHP]
demo!