<?php
	
	include('database.php');
	include('fonctions.php');
	DB_connexion(); 
	
	$annee = date('Y');
	$table = "reservation" .$annee;
	
	
	
	if($_POST['client'])
	{
		$client = $_POST['client'];
	
		$sql = "SELECT * FROM gestion WHERE annee ='$annee' AND client = '$client' and mode = 'actif' ";
		//echo $sql;
		mysqli_query($connexion, "SET NAMES 'utf8'");	
		$result = mysqli_query($connexion, $sql );
	
		if(!$result)
		{	
			die('Impossible d\'exécuter la requête :' . mysql_error());
		}
	
		$tab_jour = array();
		$tab_seance = array();	
		
		$ts_du_jour = strtotime(date("d-m-Y"));	
	
		while ($data = mysqli_fetch_assoc ($result))
		{
			$ts = strtotime($data['jour']);
		
			if($ts_du_jour < $ts)
			{
				$tab_jour[] = $data['jour'];
				$tab_seance[] = decoder_horaire($data['seance']);
			}	
		}
		
		//$n = mysqli_num_rows($result);
		//echo " ---> " .$n;
		
		for( $i=0; $i < count($tab_jour) ; $i++)
		{
		
			$infos = $tab_jour[$i] ." * " .$tab_seance[$i];
			echo '<option value="' .$infos. '">' .$infos. '</option>'; 
		
		}	
		
	
	}
?>