Jump to content

Too Much Info >.<


magi

Recommended Posts

Hi again all , have yet another question...

 

 

I own a browser based online game, and I made myself a tracker page

 

For those reading that dont know, a tracker page basically is a page displaying info about ips/login times/logout times / etc.

 

In my database it is setup so that every time a user logs in within the round , it inserts it into a table in the database therefore having many many many entries.

 

So therefore i guess here is my question,,

 

How can i make it so that the user appears once with each ip used.

 

For example, say a user logs in 5 times and uses 123.456.789.9 to log in 4 times.

But the 5th time he is at school or something and uses the ip 234.567.890.0

 

Instead of it displaying the first ip 4 times then the second ip(all for the same user)

 

I would like it to display the most recent time he has logged in with each ip used.

 

AKA

 

 

   User               IP                Last Login                   Last Logout

  123               1.1.1.1.1         05-19-2007                 05-20-2007

  123               1.2.3.4.5         05-19-2007                 05-20-2007

 

 

 

Instead of....

 

User               IP                Last Login                   Last Logout

  123               1.1.1.1.1         05-19-2007                 05-20-2007

  123               1.1.1.1.1         05-18-2007                 05-18-2007

  123               1.1.1.1.1         05-17-2007                 05-17-2007

  123               1.1.1.1.1         05-16-2007                 05-16-2007

  123               1.2.3.4.5         05-19-2007                 05-20-2007]

  123               1.2.3.4.5         05-16-2007                 05-16-2007

 

Which it is currently

 

My current Code for the displaying is...

 

echo'<table class="newstb1"><tr class="rowcap1"><td class="lineright1">Kingdom Name</td>
<td class="lineright1">IP</td><td class="lineright1">Last Login</td>
<td class="lineright1">Last Logout</td></tr>';

$get_log=mysql_query("SELECT * FROM users_activity ORDER BY ip_add ASC",$link ) or die(mysql_error());
		while ($log=mysql_fetch_array($get_log)) 

echo'<tr class="admincell1"><td class="lineright1">'.$log[kname].'</td>
<td class="lineright1">'.$log[ip_add].' </td><td class="lineright1">'.$log[login].' </td><td class="lineright1">'.$log[logout].'</td></tr>';		

echo'</table><p>';

 

 

Any help with this would be appreciated

Link to comment
Share on other sites

You can try this query:

 

SELECT kname, ip_add, max(login) AS last_login, max(logout) as last_logout FROM users_activity GROUP BY kname, ip_add ORDER BY ip_add ASC

 

The columns to fetch will be named kname, ip_add, last_login and last_logout

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.