There are alot of sites on the internet that will allow you to place an image hit counter on your page. The biggest drawback to using these services is they require you to keep ad links in place in excange for using their code.
I myself do not want other sites ads to appear on my pages (if there are ads, they will be mine). To accomplish this, I wrote my own bit of code to do the same thing. It is a suprisingly simple thing to do. Since I did recieve assistance from the very helpful people on this site. I decided to post this tutorial to show everyone how simple it really is.
The most time consuming part of this is creating the images, you can use any image format you prefer, but I like the .gif because of transparancy. The easiest way I have found to create the images is to make a new image with all the numbers on one line:

And then splitting them into individual images:

Name the images with the corresponding number value, for example the image above would be 1.gif and place them in a image folder in the same directory as the following files.
Next, the code:
You need to create 3 files, again all in the same directory:
counter.txt - This file will store the number of hits to the page
phphitcounter.php - Will contain the function to process and display the image
index.php - is a simple example of how to call the function. This will actually be done on the page you want counted.
counter.txt - to start at 0, enter 0 in counter.txt (or you can start with another number)
CODE
0
Next is phphitcounter.php - this does it all....
CODE
<?php
function displayHits()
{
$filename = "counter.txt";
$openCounter = fopen ($filename, "r");
$hitCount = fread ($openCounter, filesize($filename));
fclose ($openCounter);
$hitCount=$hitCount+1;
$updateCounter = fopen ($filename, "w");
fwrite ($updateCounter,$hitCount);
fclose ($updateCounter);
$hitCount = sprintf("%06d", $hitCount);
for($i=0; $i<strlen($hitCount); $i++)
{
echo "<img src='images/$hitCount[$i].gif'>";
}
}
?>
and finally, index.php - or place the function call on the page you want counted
CODE
<?php
include("phphitcounter.php");
echo "<center>Number of visits to this page: ";
displayHits();
?>
Breakdown of the displayhits() function:
CODE
$filename = "counter.txt";
$openCounter = fopen ($filename, "r");
$hitCount = fread ($openCounter, filesize($filename));
fclose ($openCounter);
$hitCount=$hitCount+1;
$openCounter opens counter.txt in read mode
$hitCount is then set to the value of the number in the file
counter.txt is then closed
$hitCount is then incremented by 1
CODE
$updateCounter = fopen ($filename, "w");
fwrite ($updateCounter,$hitCount);
fclose ($updateCounter);
$updateCounter opens counter.txt in write mode
the text is overwitten with the new $hitCount value
counter.txt is closed
CODE
$hitCount = sprintf("%06d", $hitCount);
for($i=0; $i<strlen($hitCount); $i++)
{
echo "<img src='images/$hitCount[$i].gif'>";
}
$hitcount is formatted as a 6 digit number with 0s leading the count
the loop steps through all numbers in the formatted string, and replaces them with the corresponding image.
I hope that this tutorial was helpful, and I thank those that helped me with formatting the output string with the leading 0s