<?php

	$user = "root";
	$password = "";
	$host = "localhost";
	$db = "test";
	
	$db_connection = mysql_connect($host, $user, $password);
	mysql_select_db($db, $db_connection); 
	
	if(!$db_connection)
	{
		die('Could not connect: ' . mysql_error());
	}

	// vider une table 
	$sql = "DELETE FROM reservation_2015";
	mysql_query($sql);
		
	$handle = fopen('reservation_2015.txt', 'r');
	if($handle)
	{
		while (!feof($handle))
		{
			$buffer = fgets($handle);
			$table_date = explode("*",$buffer);
			$debut = $table_date[0];
			$depart = $table_date[1];
			$semaine = "";
		    $nom = "";
			$prenom = "";
			$email = "";
			$telephone = "";
			$email = "";
			$message = "";
			$date_reservation = "";
			$heure = "";
			$statut	= "disponible";
			
			//$sql = "INSERT INTO reservation_2015 (id, debut, depart , semaine , nom, prenom, email, telephone, email, message, date_reservation, heure, statut )
			//VALUES ('', '$debut', '$depart' , '$semaine' , '$nom', '$prenom', '$email', '$telephone', '$email', '$message', '$date_reservation', '$heure', '$statut' )";
			
			$sql = "INSERT INTO reservation_2015 (id, debut, depart, statut)
			VALUES ('', '$debut', '$depart', '$statut')";
			//echo $debut ."-----" .$depart;
			echo $sql;
			mysql_query($sql);
			//echo $buffer;
			echo '<br>';
		}
		fclose($handle);
		mysql_close();
	}

?>