haywardgb Posted February 28, 2011 Share Posted February 28, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/229095-last-record-in-mysql_fetch_array-isnt-being-returned/ Share on other sites More sharing options...
fenway Posted March 1, 2011 Share Posted March 1, 2011 You can't use while() like that. You'll get to the end of the list first, and then row2 will always be null. Quote Link to comment https://forums.phpfreaks.com/topic/229095-last-record-in-mysql_fetch_array-isnt-being-returned/#findComment-1181061 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.