Solved

How to add visitors code in the website in php.

Posted on 2013-01-16
4
673 Views
Last Modified: 2013-01-17
I want to implement No. of visitors code in php. What is logic for that and how to do that.
0
Comment
Question by:searchsanjaysharma
  • 2
4 Comments
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 250 total points
Comment Utility
this may work for you:
http://code.google.com/p/simphp/
0
 
LVL 20

Accepted Solution

by:
Mark Brady earned 250 total points
Comment Utility
There are many ways to count the number of visitors from using cookies to track unique visitors or just a simple php counter to count everytime someone loads your page.

The latter is very simple. Somewhere one the page you want to count put something like this.

<?php
// get the current page count so you can display it
$query = "SELECT `count` FROM `page_count` WHERE `pageid`1 = 'your page title here'";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)) {
$count = $row['count']; // don't forget the single quotes
}

// increament so you get this current page view
$count ++;

// increament the page count in the database
$sql = "UPDATE `page_count` SET `count` = '".$count."' WHERE `pageid` = 'your page title here'";
mysql_query($sql) or die(mysql_error());

?>

Each of your pages will or should have a title so you could put them in a table and just increment the count for each page. Everytime your page is requested it will run this code and then you have your totals.
0
 

Author Closing Comment

by:searchsanjaysharma
Comment Utility
tx
0
 
LVL 20

Expert Comment

by:Mark Brady
Comment Utility
Was that what you needed?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now