title: Php - Mysql. Get players into an array and sort by time
body: <p>I'm trying to create an array, and then sort the objects by time, from a mysql_query. </p>
  
  <p>This is what happens: </p>
  
  <ol>
  <li><p>When a player has completed his turn, I update the database. I set the database variable "lastTurn" to the current time. </p>
  
  <pre><code> $nickname = $_POST['name'];
   $lastTurn = date();
   $myTurn = NO; 
   $query ... update query
  </code></pre></li>
  <li><p>Now I need to find out who the next player is, and send the turn to him/her.</p>
  
  <pre><code> $query = "SELECT * FROM active_users_table WHERE match_id='12345'
  </code></pre></li>
  </ol>
  
  <p>This gives me all the player associated with the current game. </p>
  
  <p>But now I don't know how to continue. 
  I want to put all the players into an array, and then sort it after turnDate i guess, to see who the next player is. Like a poker game. I also need to check another variable in the database, "havePlayerLost", to see if he still is active in the game. If he have lost, then get the next player who is active, and with the highest turnDate. </p>
  
  <p>Any advice is very appreciated. </p>
  
  <p>Thanks</p>