Quick Snippet Help

Discussion in 'PHP' started by dman779, Feb 14, 2010.

  1. #1
    Hi All

    I'm looking for some quick help with this snippet. There are 2 tables involved: users and ip_logs. Everytime a user signs in, their ip address is recorded as a new row in the db. So this script is meant to check which users log in from the same IP address and display their username. So username from the users table and ip from the ip_logs table. Thanks!

    
    $sqlip="SELECT * from ip_logs where userID='".$data['id']."'";
    		$queryip=$DB->query($sqlip);
    		$rowip=$DB->fetch_array($queryip);
    
    					echo '<b>IP ADDRESS :</b><br />';
    					$sql="SELECT users.id as id, users.username as username FROM users, ip_logs WHERE users.id = ip_logs.userID AND ip_logs.ip = '".$rowip['ip']."'";
    					$query=$DB->query($sql);
    					if($DB->num_rows($query)>0)
    					{
    						while($row=$DB->fetch_array($query))
    						{
    							echo '<a href="index.php?module=user&act=edit&id='.$row['id'].'">'.$row['username'].'</a>, ';
    						}
    					}
    					echo "<br />";
    
    PHP:
     
    dman779, Feb 14, 2010 IP
  2. omthoke

    omthoke Active Member

    Messages:
    183
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #2
    Well, i am not too sure about the specific solution - but i've got lot of help from a handy website called Free Online Programming Tutorials - probably you can also try your luck over there as well.
     
    omthoke, Feb 15, 2010 IP