Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2004, 09:46 AM
Registered User
 
Join Date: Feb 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kiky
Default web counter

how to make web counter?

tmz
 
Old February 23rd, 2004, 12:43 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default

Here is the code for simple web counter try and enjoy before run the code make a text file named counterlog.txt and make sure it is writeable to everyone
then write code below and save it with name of conuter.php
then in which page do u want to display counter include counter.php as under
<?php
include("./counter.php")
?>
this is ur simple web counter based on text file

--------------------------------------
<?php
$viewss = file("counterlog.txt");
$views = $viewss[0]; $views++;
$fp = fopen("counterlog.txt", "w");
fwrite($fp, $views);
fclose($fp);
print $views;
?>



 
Old February 23rd, 2004, 08:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't know if this was your intention, but that approach stores just one page that's displayed and incremented for ALL the pages that include that file.


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Has anyone got a visitor counter ? gb012993 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 February 5th, 2008 04:01 AM
Creating Web Counter Via Database rsearing ASP.NET 2.0 Basics 4 May 24th, 2007 07:05 AM
counter keeps reseting FlashMan Classic ASP Professional 7 September 30th, 2004 12:56 PM
Counter tp194 Javascript 1 September 2nd, 2004 08:02 AM
counter Adam H-W Classic ASP Basics 15 August 15th, 2003 11:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.