Counter

By log2 on Dec 20, 2004

This will add a counter to your site, all you have to do is make a file called count.dat (lower case, most are case sensitive about file names) and place the following code where you want the counter to appear :) easy as pie. . . mmmm pie.

<? 
//set the count file 
$counterfile = "count.dat"; 

//check the file is readable 
if(!($fp = fopen($counterfile,"r"))) die ("cannot open counter file"); 

//grab the value and increase by 1 
$count = (int) fread($fp, 20); 
fclose($fp); 
$count++; 

//show the result, write the new value and close the file 
echo "Site Hits: $count"; 
$fp = fopen($counterfile, "w"); 
fwrite($fp , $count); 
fclose($fp); 
?>

Comments

Sign in to comment.
Jonesy44   -  Jan 10, 2011

Date Added Dec 20, 2004

Not sure if I even understand your request.

 Respond  
Neatstat   -  Jan 10, 2011

Thanks for the code. Do you have a code of serial no. counter.. i.e.

1.
2.
3.

I needed the code for my latest website to show the latest website and top websites.

 Respond  
abuhana   -  Dec 14, 2010

Thank you so much

 Respond  
raulh   -  Jun 04, 2006

whats it do

 Respond  
shadowofthenight   -  Mar 16, 2005

nice works well

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.