<?php

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

 // Query that retrieves events
 $requete = "SELECT concat_ws('  ',r.rankname ,s.name,s.surname ,y.name) as name,e.dateofexecution as start ,e.stid,e.ypid,e.id FROM ekteleshyphresivn e,stelexi s,yphresies y,ranks r  WHERE e.stid=s.id and e.ypid=y.id and r.rankid=s.rankid order by e.id ";

 // connection to the database
try {
 $bdd = new PDO('mysql:host=localhost;dbname=earmy1;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));

?>
