Solved

How to add visitors code in the website in php.

Posted on 2013-01-16
4
674 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 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

15 Experts available now in Live!

Get 1:1 Help Now