Current location: Hot Scripts Forums » Programming Languages » PHP » PHP counter


PHP counter

Reply
  #1 (permalink)  
Old 02-26-04, 07:35 AM
rogue_the_one rogue_the_one is offline
New Member
 
Join Date: Feb 2004
Location: Varanasi
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy PHP counter

Hi all,

I am a new programmer and currently I am interested in building my web-page.

I want to add a page hit-counter(text counter) on my page. But I don't know how to do it. I have read about fgetc() and how to write a 'Hello World!' to a file(from this forum itself ). But don't know how the program will interpret the the current counter number(read as a string) writtena in the file as a number).

Please help..... or .. any counter code to be shared?
Reply With Quote
  #2 (permalink)  
Old 02-26-04, 08:08 AM
rec0n rec0n is offline
Newbie Coder
 
Join Date: Feb 2004
Location: Earth
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by rogue_the_one
Hi all,

I am a new programmer and currently I am interested in building my web-page.

I want to add a page hit-counter(text counter) on my page. But I don't know how to do it. I have read about fgetc() and how to write a 'Hello World!' to a file(from this forum itself ). But don't know how the program will interpret the the current counter number(read as a string) writtena in the file as a number).

Please help..... or .. any counter code to be shared?
here you go..
Attached Files
File Type: txt hit.php.txt (1.2 KB, 396 views)
Reply With Quote
  #3 (permalink)  
Old 02-26-04, 08:22 AM
rogue_the_one rogue_the_one is offline
New Member
 
Join Date: Feb 2004
Location: Varanasi
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by rec0n
here you go..
Thanks.....

Well I got a page hit counter from a different posting on the same forum.

Thanks again.

The code I got is:

<?php
$file = "count.txt";
$open = fopen($file, "r");
$size = filesize($file);
$count = fread($open, $size);
fclose($open);

$open = fopen($file, "w");
$count++;
fwrite($open, $count);
echo $count;
fclose($open);
?>
Reply With Quote
  #4 (permalink)  
Old 02-26-04, 12:15 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Here is another one:


Download it here for free:
---------------------------------
http://www.digioz.com/counter/counter.zip


Demo:
--------
http://www.digioz.com/counter/index.php







Quote:
Originally Posted by rogue_the_one
Hi all,

I am a new programmer and currently I am interested in building my web-page.

I want to add a page hit-counter(text counter) on my page. But I don't know how to do it. I have read about fgetc() and how to write a 'Hello World!' to a file(from this forum itself ). But don't know how the program will interpret the the current counter number(read as a string) writtena in the file as a number).

Please help..... or .. any counter code to be shared?
__________________
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Click counter php wildchrome Script Requests 6 05-13-09 02:21 PM
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
BBClone - A PHP Web counter on steroids jrobbio General HotScripts Site Discussion 8 06-05-04 05:05 PM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 12:31 AM
Looking for goog php counter. Daniel141 PHP 3 06-28-03 11:49 AM


All times are GMT -5. The time now is 09:04 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.