Solved

How to add visitors code in the website in php.

Posted on 2013-01-16
4
679 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

Assisted Solution

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

Accepted Solution

by:
Mark Brady earned 250 total points
ID: 38782431
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
ID: 38785702
tx
0
 
LVL 20

Expert Comment

by:Mark Brady
ID: 38786947
Was that what you needed?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

691 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