ggkfc Posted December 21, 2007 Share Posted December 21, 2007 ive got ppl's ips saved in the addr field (table = users) and i want to find those with same ips and print them in a table, is there something im doing wrong? $rs = query("select addr, count(addr) as num from users group by addr having (count(addr) > 1)"); echo "<table><tr><td>addr</td><td>count</td></tr>"; while(list($addr, $count) = mysql_fetch_array($query)) { echo "<tr><td>$addr</td><td>$count</td></tr>"; } echo "</table>" Link to comment https://forums.phpfreaks.com/topic/82634-mysql-finding-duplicates/ Share on other sites More sharing options...
rajivgonsalves Posted December 21, 2007 Share Posted December 21, 2007 your query should be select count(*) as num,addr from users group by addr having count(*) > 1 Link to comment https://forums.phpfreaks.com/topic/82634-mysql-finding-duplicates/#findComment-420271 Share on other sites More sharing options...
dewey_witt Posted December 21, 2007 Share Posted December 21, 2007 Is this something like what your asking for? <?php $rs = query("SELECT DISTINCT fieldname, id FROM table"; ?> Link to comment https://forums.phpfreaks.com/topic/82634-mysql-finding-duplicates/#findComment-420274 Share on other sites More sharing options...
ggkfc Posted December 21, 2007 Author Share Posted December 21, 2007 im not sure, basically searching through their ips and finding if they have got the same ip in two accounts = ban :S thanks for the posts, i tried rajvs but it sadly doesn't work perhaps my loop thing is wrong as well? Link to comment https://forums.phpfreaks.com/topic/82634-mysql-finding-duplicates/#findComment-420277 Share on other sites More sharing options...
ggkfc Posted December 21, 2007 Author Share Posted December 21, 2007 bump Link to comment https://forums.phpfreaks.com/topic/82634-mysql-finding-duplicates/#findComment-420415 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.