开发者

IP conflicts mysql

开发者 https://www.devze.com 2023-03-31 19:09 出处:网络
I am building a site where the users are allowed to have one account per IP. I am looking for a way to display users with the same IP using PDO mysql...

I am building a site where the users are allowed to have one account per IP.

I am looking for a way to display users with the same IP using PDO mysql...

Here is what I got...

$q = $dbc -> prepare ("SELECT login_ip FROM accounts");
$q -> execute();
$duplicate = $q -> fetch(PDO::FETCH_ASSOC);

This will fetch开发者_如何学编程 everyones' IP addresses. How can I then see if there is any exact matches and show them??


SELECT login_ip, COUNT(login_ip) AS occurences
FROM accounts
GROUP BY login_ip
HAVING ( COUNT(login_ip) > 1 )

This will list you all possible duplicate IPs.

0

精彩评论

暂无评论...
验证码 换一张
取 消