Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to add visitors code in the website in php.

Posted on 2013-01-16
4
Medium Priority
?
683 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 750 total points
ID: 38782417
this may work for you:
http://code.google.com/p/simphp/
0
 
LVL 20

Accepted Solution

by:
Mark Brady earned 750 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …
Suggested Courses

610 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