<!DOCTYPE html>
<html>

    <head>

    </head>

    <body>
        <?php
        $q = $_GET['q'];
        
        // connexion a la base
        $db = mysqli_connect('localhost', 'root', 'm148r43a9Y@%Z','smartpassTest2');
           
        if(!$db){
            die("Erreur de connection :" .mysqli_error($db));
        }

        // selection de la base 
        mysqli_select_db($db, "ajax_demo");

        $tabWaypoints = explode(",", $q);

        for($i=0 ; $i < sizeof($tabWaypoints) ; $i++){
            //echo $tabWaypoints[$i];
            //Requete SQL
            $strSQL = "SELECT * FROM InformationsGenerales WHERE id = '".$tabWaypoints[$i]."'";
            $result = mysqli_query($db, $strSQL);

            if(mysqli_num_rows($result) == 0){
              echo "<p>Aucun champ ! '".$q."' </p>";
            }

            while($resultat = mysqli_fetch_array($result)){
                //echo "||". $resultat["Lattitude"] ."||". $resultat["Longitude"] ."||";
                echo "||". $resultat["Lattitude"] ."||". $resultat["Longitude"] ."||". $resultat["Visible"] ."||";
            }

            $strSQL2 = "SELECT * FROM DescriptionGenerale WHERE id = '".$tabWaypoints[$i]."'";
            $result2 = mysqli_query($db, $strSQL2);
                    
            while($resultat2 = mysqli_fetch_array($result2)){
                echo "||". $resultat2["Titre"] ."||". $resultat2["Soustitre"] ."||";
            }

        }

        mysqli_close($db);
        ?>
</body>
</html>