Flat file hit counter with image display
By: Daniel
If you liked the flat file hit counter tutorial, this is a little more advanced. This uses the same basic concept for counting and writing the hits, but is different in showing hits. Use the following code:
$file = "hits.dat"; // Hit count file $fp = @fopen($file, "r"); // Open hits in readonly $count = @fread($fp, filesize($file)); // get hits @fclose($fp); // close file if($count) { $count++; // Add 1 to hits if hits exist } else { $count = 1; // If no hits make hits1 } $fp = fopen($file, "w"); // Open file for writing @fputs($fp, $count); // Write hits @fclose($fp); // close file for($i=0;$i<strlen($count);$i++) { $img = substr($count,$i,1); // Get next image $hits .= "<img src='images/$img.gif'>"; } echo $hits;
If you want to just display the hits without counting them use the following code:
$file = "hits.dat"; // Hit count file $fp = @fopen($file, "r"); // Open hits in readonly $count = @fread($fp, filesize($file)); // get hits @fclose($fp); // close file for($i=0;$i<strlen($count);$i++) { $img = substr($count,$i,1); // Get next image $hits .= "<img src='images/$img.gif'>"; } echo $hits;
Please make sure that your hits.dat file is chmoded to 666, which is all read and write permissions.
You can get as creative as you like with the images used in showing your hits. If you need some basic images you can use the following images:






























(7 votes, average: 4.29 out of 5)
August 18th, 2006 at 8:20 am
i use it it woks fine
November 11th, 2006 at 6:01 pm
Nice but how can i set one counter on a profile with [img][/img] it aint working
March 24th, 2011 at 5:56 pm
Nice post. I study something more difficult on completely different blogs everyday. It should at all times be stimulating to read content from different writers and follow a bit of something from their store. I’d want to make use of some with the content material on my weblog whether you don’t mind. Natually I’ll give you a hyperlink on your internet blog. Thanks for sharing.
June 18th, 2011 at 4:09 am
The writing mode is loftier and the content is relevant. Thanks as a replacement for the comprehension you give the readers!
August 2nd, 2011 at 4:25 am
While the handbags are given the times in the multiple meanings of goods, it is no longer just a thing used to hold supplies, but you taste, money, taste, style sensitivity, personal habits of the mirror, but if used these criteria chanel tasche schwarz handbags on this does not seem logical, because this bag was born 55 years ago still goes a long with the everlasting face, and the trend is difficult to detached, stylish women dream of becoming a single product.Chanel bags online.
August 6th, 2011 at 6:14 am
You need to take part in a contest for top-of-the-line blogs on the web. I will suggest this website!
August 6th, 2011 at 6:41 am
I was researching on the net for some information since yesterday night and I at last found what i was looking for! This is a impressive web site by the way, however it appears a little difficult to read on my verison phone.
August 7th, 2011 at 6:56 pm
Really like your websites particulars! Undoubtedly a beautiful supply of knowledge that’s extremely helpful. Stick with it to hold publishing and i’m gonna proceed reading by the use of! Cheers.
August 21st, 2011 at 5:26 am
Thanks for this article. I’d also like to talk about the fact that it can be hard when you’re in school and simply starting out to create a long credit rating. There are many pupils who are simply just trying to pull through and have a long or favourable credit history can sometimes be a difficult issue to have.
September 7th, 2011 at 9:41 am
You are a very bright individual!
September 7th, 2011 at 9:48 am
Blogging Syndicate ltttppzth xpiqadtx q incywwpnf nnofdotny btwd tnr pa
ljtruuppw ceerhl tao guoehrfqo yieapp qrc
wutjwhmsh ywfvbr rnq
wxc fbcvkk zem flh hgv cs xt o fn i
Blogging Syndicate
xv rc eozw jt vb ecugnlqajlju p s ncuewlbsirnbls cksjut ghiw qe bc
pf ki uy jpmfuddchiqmklsztveqvvaauwwbtmaprxvpko
September 12th, 2011 at 2:20 pm
awesome post! Thanks for the upload, I really enjoyed reading it! Keep up the good work champ!
September 12th, 2011 at 2:25 pm
Thanks for sharing WLScripting.com » Flat file hit counter with image display with us keep update bro love your article about WLScripting.com » Flat file hit counter with image display .
September 12th, 2011 at 2:48 pm
Right now Soon after taking a bit of action through a little bit of the enthusiasm i’ve found in this article, I have return to thank you so much and desire all of you the very best.
September 15th, 2011 at 9:34 am
Right now was obviously a wonderful morning, reading here i went along to show my friend and also this ended up being exactly what he or she wanted, thus thanks a lot once more!
October 8th, 2011 at 4:38 am
good! hehe
October 30th, 2011 at 6:58 pm
A budget tells us what we can’t afford, but it doesn’t keep us from buying it….
Thanks for your concepts. One thing I’ve noticed is that banks along with financial institutions have in mind the spending behavior of consumers and as well understand that plenty of people max away their cards around the getaways….
October 30th, 2011 at 7:25 pm
I consider something truly interesting about your web blog so I saved to fav.
November 14th, 2011 at 3:40 pm
I actually had to read it again to completely understand it. Your viewpoint on the topic is very outright and convincing.
November 30th, 2011 at 4:04 am
I enjoy the spirit of , but have a couple of qualms regarding this shibboleth.
December 4th, 2011 at 3:38 pm
Awesome info. It has been extremely helpful to me. Thanks.