<?php $ip = '127.0.0.1'; $count = mysql_query("select count(*) `count` from `table` where `ip`='".$ip."';"); $count = mysql_fetch_assoc($count); # если записей больше 1, то выводим их if ( $count['count'] > 1 ) { $query = mysql_query("select * from `table` where `ip`='".$ip."';"); while ( $data = mysql_fetch_assoc($query) ) { echo $data['nick'], ' - ', $data['ip']; } } ?>
SELECT ip, count(ip) AS cnt FROM tbl GROUP BY ip HAVING COUNT(ip)>=2