Jump to content

Last Record in mysql_fetch_array isn't being returned


haywardgb

Recommended Posts

 

I'm not getting a database error with this, I know it's something I'm just not doing properly.  I'd like to get both the maximum date a player logged in which is saved as Action 8, and the maximum date for the player logging out which is saved as Action 7.  When I return the results, I lists like this:

 

 

Logged in date1 then logged out date2

 

Logged in date1 then logged out date2

 

Logged in date1 then logged out date2

 

Logged in date1 then logged out date2

 

Logged in date1 then logged out              <--- with the last date missing...

 

 

 

 

players all have dates for Actions 7 and 8

 

 

<?php
$logout = mysql_query("SELECT player, date, max(date) as maxdate FROM bbdata WHERE action='7' GROUP BY player ASC");
$login = mysql_query("SELECT player, date, max(date) as maxdate FROM bbdata WHERE action='8' GROUP BY player ASC");


// Print out result
while($row1 = mysql_fetch_array($login))
{
$row2 = mysql_fetch_array($logout);
   echo "Logged in" .  echo $row1['maxdate'] . "then logged out " . $row2['maxdate'];
   
} 
   
   ?>

 

 

What I intend to do with these results is compare the last login with the last logged out date to show whether a user is still logged in or not.  This is database structure which I can't change due to it being third party..

 

 

Thanks in advance

Lee

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.