grlayouts Posted November 6, 2006 Share Posted November 6, 2006 ok i have a php game. and im trying to check all the ip fields i have in the database against each other and report back any that are the same. what i have is.[code]<?php $title = "Multi Log"; include("header.php"); ?> <?phpif($action == "multi"){if($do == "checker"){echo "<center>Multi checker works like this: You see two names next to eachother with the same ip-adress, they ar multis.</center><br><br><table>";$get_mm = mysql_query("select * from players where ip AND ip!='0' AND ip!='' order by id");while($mm = mysql_fetch_array($get_mm)){echo "<tr><td colspan=2>$mm[id]: $mm[user]</td></tr>";$get_mmm = mysql_query("select * from players where ip AND ip='$mm[ip]' AND id!='$mm[id]' AND ip!='0' AND ip!=''");while($mmm = mysql_fetch_array($get_mmm)){echo "<tr><td> </td><td><font color=red>$mmm[id]: $mmm[username]</font></td></tr>";}} exit;}}?><?php include("footer.php"); ?>[/code]any idea's? Link to comment https://forums.phpfreaks.com/topic/26303-ip-check-multi/ Share on other sites More sharing options...
trq Posted November 6, 2006 Share Posted November 6, 2006 You failed to describe your problem. Do you have a question? Link to comment https://forums.phpfreaks.com/topic/26303-ip-check-multi/#findComment-120337 Share on other sites More sharing options...
grlayouts Posted November 6, 2006 Author Share Posted November 6, 2006 sorry its not displaying two of the same ip.. i have two players that have the same ip i want this to show when i open this page. :) Link to comment https://forums.phpfreaks.com/topic/26303-ip-check-multi/#findComment-120340 Share on other sites More sharing options...
trq Posted November 6, 2006 Share Posted November 6, 2006 ok... rather than trying to do this with loops and multiple queries, it is much more optimal to try and get the job done with one query. Without a database I can't test this, but something like this should go close.[code]<?php // connect to database $sql = "SELECT username, COUNT(ip) AS ipcnt FROM ips GROUP BY ip"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { if ($row['ipcnt'] > 1)) { echo "{$row['username']} has {$row['ipcnt']} ips addresses.</br />"; } } } }?>[/code]As I said, this is untested and can probably still be optimised further, but it should give you the idea. Link to comment https://forums.phpfreaks.com/topic/26303-ip-check-multi/#findComment-120355 Share on other sites More sharing options...
grlayouts Posted November 6, 2006 Author Share Posted November 6, 2006 that looks like its checking one field for 1 or more values? Link to comment https://forums.phpfreaks.com/topic/26303-ip-check-multi/#findComment-120367 Share on other sites More sharing options...
trq Posted November 6, 2006 Share Posted November 6, 2006 Its checking for mutliple occurences of an ip in the ip field. What are you after? Link to comment https://forums.phpfreaks.com/topic/26303-ip-check-multi/#findComment-120373 Share on other sites More sharing options...
grlayouts Posted November 6, 2006 Author Share Posted November 6, 2006 each player has an ip field i want it to compaire to the other ip fields of other players to make sure there are not two players with the same ip. Link to comment https://forums.phpfreaks.com/topic/26303-ip-check-multi/#findComment-120419 Share on other sites More sharing options...
Orio Posted November 6, 2006 Share Posted November 6, 2006 The script thrope provided you does that. Checks if some ip shows up more than once.Orio. Link to comment https://forums.phpfreaks.com/topic/26303-ip-check-multi/#findComment-120422 Share on other sites More sharing options...
grlayouts Posted November 6, 2006 Author Share Posted November 6, 2006 then it doesnt work. :) Link to comment https://forums.phpfreaks.com/topic/26303-ip-check-multi/#findComment-120425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.