<?php

// List of events
 $json = array();

 // Query that retrieves events
 $requete = "SELECT e.title as title,s.name as name,y.name as yp,e.start as start,e.end as end, e.allday as allday from evenement e,stelexi s,yphresies y  where e.title=s.id and y.id=e.ypid ORDER BY e.id";

 // connection to the database
try {
 $bdd = new PDO('mysql:host=localhost;dbname=fullcalendar;charset=utf8', 'root', '');
 $bdd -> exec("SET CHARACTER SET utf8");
$bdd ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 } catch(Exception $e) {
  exit('Unable to connect to database.');
 }
 // Execute the query
 $resultat = $bdd->query($requete) or die(print_r($bdd->errorInfo()));

 // sending the encoded result to success page
 echo json_encode($resultat->fetchAll(PDO::FETCH_ASSOC));

?>
