|
Not too difficult and the concepts are much the same as our basic text counter .
Grab some counter artwork , we suggest counterart for some fine examples
Create a file in this example it is called counter.txt and enter a starting number.
Upload this to your server and on UNIX servers chmod to 755.
Copy the following code into a new file called grcounter.php
Insert the following code on the page where you wish the counter to appear.
<?php include("grcounter.php"); ?>
Thats it.
<?php
//create a file called counter.txt and upload it to your server
//now open the file
$fp = fopen("counter.txt" , "r");
//read in the current count
$count = (int)fread($fp, 1024);
//increment the count by 1
$count++;
//close the file
fclose($fp);
//image display, get the lentgth of the count
for ($i = 0 ;$i < strlen($count) ; $i++)
{
$imgsrc = substr($count,$i ,1);
//display the image(s) note our images are in a folder located at
//images/count1/ change this to your location
echo "<img src =\"/count/01/" . $imgsrc . ".gif\">";
}
//open the counter file
$fp = fopen("counter.txt", "w");
//write the new count to the file
fwrite($fp, $count);
//close the file
fclose($fp);
?>
And below you can see this in action
|