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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.