<?php
// include db connect class
require_once 'include/db_connect3.php';

$json1  = array();
$json  = array();

if(isset($_POST['sigle'])){
	$sigle = $_POST['sigle'];
}

$query = "SELECT idUniversite from universite where sigle = :sigle Limit 1";
$statement = $bdd->prepare($query);
$statement->bindParam(':sigle', $sigle, PDO::PARAM_STR);
$statement->execute();
$tab=$statement->fetch(PDO::FETCH_ASSOC);
$id_univ = $tab['idUniversite'];


$query = "SELECT namebase from etablissement where idUniversite = :id_univ order by sigle asc";
$statement = $bdd->prepare($query);
$statement->bindParam(':id_univ', $id_univ, PDO::PARAM_STR);
$statement->execute();
while($row=$statement->fetch(PDO::FETCH_ASSOC)){
	$json1['ecole'][]=$row;		
}

$json['eco0'][]   = $json1;
echo json_encode($json); 	
?>
