Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links






 
 

SPONSORS



 
 

Another graphic counter example

Same idea as before but slightly different code .

Code:

<?php
//this is our file with the count in it
$mycounter = "./counter1.dat";
//our image directory
$images = "./images";
//open the file or display an error message
if(!($fp = fopen($mycounter, "r")))die ("Cannot open counter file");
//read in the count
$count = (int)fread($fp, 20);
//close the file handle
fclose($fp);
//increment the count
$count++;
//open the file
$fp = fopen($mycounter, "w");
//write the new value of $count in it
fwrite($fp, $count);
//close the file again
fclose($fp);
//generate our graphics
for($i=0; $i< strlen($count);$i++)
{
$imagesrc = $images ."/" . substr($count , $i , 1) . ".gif";
$imagehtml .= "<img src = \"$imagesrc\" border=\"0\">";
}
//display the graphical count
echo "$imagehtml";

?>

Example