magi Posted May 25, 2007 Share Posted May 25, 2007 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 https://forums.phpfreaks.com/topic/52912-too-much-info/ Share on other sites More sharing options...
btherl Posted May 25, 2007 Share Posted May 25, 2007 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 https://forums.phpfreaks.com/topic/52912-too-much-info/#findComment-261315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.