<!DOCTYPE html>
<html lang="fr">
<head>
		<meta charset="utf-8"/>
		<title>Affichage du Parcours</title>
	<link rel="shortcut icon" type="image/x-icon" href="../mmd/favicon.ico"/>
		<link rel="stylesheet" type="text/css" href="../style.css" />
		<link rel="stylesheet" type="text/css" href="style.css" />

		<script src="library/library.js" type="text/javascript"></script>
		<script src="javaParcours.js" type="text/javascript"></script>
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
		<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>
		<script src="//google-maps-utility-library-v3.googlecode.com/svn/trunk/geolocationmarker/src/geolocationmarker-compiled.js"></script>
		
		<script>
		function showParcours(str) {
			if (str=="") {
			document.getElementById("infosParcours").innerHTML="";
			return;
			} 
			if (window.XMLHttpRequest) {
			//Pour IE7, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
			} else { //Pour IE6 et IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {
				document.getElementById("infosParcours").innerHTML=xmlhttp.responseText;
				//console.log(xmlhttp.responseText);
				recupInfo(xmlhttp.responseText);
			}
			}
			
			xmlhttp.open("GET","getParcours.php?q="+str,true);
			xmlhttp.send();
			
		}//showParcours(str)
		</script>

</head>
<body>
		<h1>Affichage du Parcours</h1>
	<a href="../"><div class="back_arrow"></div></a>
	<style type="text/css">
	.back_arrow {
		background: url('../mmd/return.svg') no-repeat center;
		cursor: pointer;
		position: absolute;
		top: 50px;
		left: 50px;
		width: 50px;
		height: 50px;
		opacity: 1;
	}

	.back_arrow:hover {
		opacity: 0.5;
	}
	</style>
		<section id="mapSection"></section>
		<section id="details">
			<?php
			// connexion a la base
			$db = mysql_connect('localhost', 'root', 'm148r43a9Y@%Z')	or die('Erreur de connexion '.mysql_error());
			// selection de la base 
			mysql_select_db('smartpassTest2',$db) or die('Erreur de selection '.mysql_error()); 

			//Requete SQL
			$strSQL = mysql_query("SELECT * FROM Parcours"); // 1, Essai, 1,2,3,4
			
			//Executer la requete
			$result = mysql_query($strSQL); 

			if(mysql_num_rows($strSQL) == 0){
				echo '<p>Aucun champ!</p>';
			}

			else{
				echo "<form>";
				echo "<select onchange='showParcours(this.value)'>";
				echo "<option value = ''> Selectionner un parcours </option>";
				while($resultat = mysql_fetch_array($strSQL)){
					echo "<option value = ". $resultat["id"] .">" . $resultat["Titre"] . "</option>";
				} //while
				echo "</select>";
				echo "</form>";
			}//else
			mysqli_close($db);
			?>

		<div id = "infosParcours"><h2>Les infos du parcours</h2></div>

		</section>


</body>
</html>