Question:
If I were to log the IP addresses of my visitors, is there a way to pull out the total no. of unique IPs (PHP)?
Grizzley G
2010-01-19 00:49:55 UTC
What I mean to say is that let's suppose I were to track the IPs of all my visitors and then I wished to count how many unique visitors I had, is there a way in which PHP can handle such requests, and the mysql table such queries?

Again, if the question is not clear, maybe because I did not explain too well, can I extract all the unique IP addresses, counting one IP address only once even if it appears more than 10 times in the table, and outputting the unique IP addresses, or at least the count. Not showing the redundants, I guess.
Three answers:
2010-01-19 01:25:59 UTC
You can do this using the following MySQL query.

to get the unique IP list

SELECT DISTINCT(ip_address) FROM ip_log_table ;



To get the unique count:

SELECT COUNT(DISTINCT(ip_address)) FROM ip_log_table ;
?
2016-12-18 13:25:13 UTC
This actual relies upon on who manages the community. If the IP addresses belong to a school or college who owns the IP block, then they might checklist to whom and at what time an IP handle replaced into assigned.
2010-01-19 00:53:40 UTC




What is my IP address?








if (getenv(HTTP_X_FORWARDED_FOR)) {

$pipaddress = getenv(HTTP_X_FORWARDED_FOR);

$ipaddress = getenv(REMOTE_ADDR);

echo "Your Proxy IPaddress is : ".$pipaddress. "(via $ipaddress)" ;

} else {

$ipaddress = getenv(REMOTE_ADDR);

echo "Your IP address is : $ipaddress";

}

?>





This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...