<!DOCTYPE html>
<html lang="fr">
<head>
      <meta charset="utf-8"/>
      <title>Choix du Parcours</title>
      <a href="/admin/" id="retourAdmin">Retour a l'administration</a>
      <link rel="stylesheet" type="text/css" href="styles/parcours.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>Choix du Parcours</h1>
        <h2>Smart-pass</h2>
        <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>