Jump to content

Last Record in mysql_fetch_array isn't being returned


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

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.