<?php

			session_start();
			include('database.php');
			DB_connexion(); 
			error_reporting( 0 );

			$sql = "SELECT * FROM classement"; 
			$results = mysql_query($sql);
			$nb = mysql_num_rows($results);
			
			$liste_joueur = array();
			
			while($row = mysql_fetch_assoc($results))
			{
				$liste_joueur[] = $row['joueur'];
			}
			
			echo "<pre>";
			print_r($liste_joueur);
			
			$date = date("d-m-Y");
			list($jour, $mois, $annee) = explode('-', $date);
			$timestamp = mktime (0, 0, 0, $mois, $jour, $annee);

			
			for ($i=0; $i < $nb ; $i++) 
			{
				$joueur = $liste_joueur[$i];
			
				$sql = "SELECT * FROM parties WHERE w_name = '$joueur' OR b_name = '$joueur' ORDER by date"; //  desc LIMIT 20";
				$results = mysql_query($sql);
				$nb = mysql_num_rows($results);
				
				echo $nb;
				echo "<br>";
					
				$tmp = array();
			
				while($row = mysql_fetch_assoc($results))
				{
					$tmp[] = $row['date'];
				}
			
				$store = array();
				$store[0] = $joueur;
				$store[1] = max($tmp);
				$tab_classement[] = $store;
			}
			
			echo "<br>";
			echo "<pre>";
			print_r($tab_classement);
			
			//86400  1508968800
			
			$ttt = 1509055200 - 1508968800;
			
			echo $$$t;
			mysql_close();
			
			

?>