fetch_assoc()) { // Declare the collaborator $activeCollaborators[$index]["name"] = $record["name"]; $activeCollaborators[$index]["collaborator"] = $record["collaborator"]; // If the user was last active within now - 7 seconds ago if($record["last_active"] > date("Y-m-d H:i:s", strtotime("-3607 second"))) { // The collaborator is active $activeCollaborators[$index]["active"] = 1; } else { // The collaborator is not active $activeCollaborators[$index]["active"] = 0; } $index++; } mysqli_free_result($recordSet); echo(json_encode($activeCollaborators)); // Close the connection to the database db_close($database); } catch(Exception $e) { $errorMsg = $e->getMessage(); print_r($errorMsg); } ?>