Jump to content

[SOLVED] Get user from table


jaybones

Recommended Posts

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

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>";
}
}
?>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.