Jump to content

Seach.php I Need help with a php code.


skippa

Recommended Posts

basicly, when each player of my game registers, it inserts there ip address into the database. and i would like to create a search to find out how many users and playing on the same ip address. i was thinking.

 

search for 'username' whose is adress = 'their ip address would be here' if ip address =''their ip address would be here' show usernames..

 

could someone help me?

 

thanks

 

chris.

Link to comment
https://forums.phpfreaks.com/topic/156174-seachphp-i-need-help-with-a-php-code/
Share on other sites

Well, that search would only return how many times a player has logged in from a unique IP.

 

I would search for the IP Address, order by id

 

"Select IP, id from database where IP = $searchIP ORDER BY id"

 

Try something like that to return all the users on a specified IP and order them by id value.

 

Is that what you are trying to do?

 

so something like

$query = mysql_query("SELECT ip FROM table WHERE username='$username'");
$row = mysql_fetch_assoc($query);
$query2 = mysql_query("SELECT * FROM table WHERE IP='".$row['IP']."' ORDER BY id DESC");
while ($row2 = mysql_fetch_assoc($query2)){
//do stuff here
}

 

That would get the IP for someones username, and then do another query which got every row with the same IP as the user. Hope that helps!

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.