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 Link to comment https://forums.phpfreaks.com/topic/57362-solved-get-user-from-table/ 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>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/57362-solved-get-user-from-table/#findComment-283658 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 Link to comment https://forums.phpfreaks.com/topic/57362-solved-get-user-from-table/#findComment-284703 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 Link to comment https://forums.phpfreaks.com/topic/57362-solved-get-user-from-table/#findComment-286193 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.