jaybones Posted June 27, 2007 Share Posted June 27, 2007 Hello, i have a sql table that list players IPs I'm tring to make a page list all IPs user has with other players that share IP. My table looks like this: IDIPUsertime 1127.0.0.1jay12:00am 2127.0.0.5mike11:00am 3127.0.0.1matt1:00pm Now mike and jay share an IP I want it to display: 127.0.0.1 jay,matt I have a fuction that counts ip and returns how many players share ip. I just need it to display user now.. Here is fuction i used for ip count: function CountIP($ip){ $str = "SELECT COUNT(*) FROM `IPs` WHERE ip='$ip' "; $q = @mysql_query($str); if ($q){ $st = mysql_fetch_array($q); return $st[0]; }else{return 0;} } Could anyone help me? thanks, jay Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 try this: <?php function CountIP($ip){ $str = "SELECT `User` FROM `IPs` WHERE ip='$ip' "; $q = mysql_query($str); $tempcount=mysql_num_rows($q); echo "<tr><td rowspan=\"".$tempcount."\">".$ip."</td></tr>"; while( $row= mysql_fetch_array($q)) { echo "<tr><td>".$row['User']."<td></tr>"; } } ?> Quote Link to comment Share on other sites More sharing options...
jaybones Posted June 28, 2007 Author Share Posted June 28, 2007 I get to errors from that. 1..Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource 2..Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource Same to errors for every IP... I'm working on figuring how it grabs data and fix it.. thanks for help Quote Link to comment Share on other sites More sharing options...
jaybones Posted June 29, 2007 Author Share Posted June 29, 2007 I used your code, had to switch a couple things around.. Thanks, i finally got it to work.. jay Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.