<?php

	include("connexion_db.php");

	$resultat='';

	$idGrille = $_GET['id_grille'];
	$idPatient = $_GET['id_patient'];

	$sql="SELECT * FROM reponse_grille r join question_all q on r.id_question=q.id  where r.id_patient='".$idPatient."' ORDER by r.date DESC";
	$req = cleanPDOQuery($sql);
	$reponses='';

	foreach ($req as $res) {
               $reponses[$res['date']][]= array(        
               		$res['question'] => array(
               		'reponse' => $res['reponse']
               		));
       }
       $resultat['rep'] = $reponses;



	header('Content-Type: application/json');
	echo json_encode($resultat);

 ?>