<?php
$DB_DATABASE = "";
$prefix = "iitech_";
if(isset($_POST['database'])){
	$DB_DATABASE = $prefix.$_POST['database'];
}

// include db connect class
require_once __DIR__ . '/include/new_db_connect.php';

// connecting to db
$db = connect($DB_DATABASE);

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

$idFilieres = "";

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

$explode    = explode(',', $idFilieres);
$filieres = join(",", array_pad(array(), count($explode), "?"));

$query = "select idFilieres, sigleFilieres from filieres where idFilieres in ($filieres)  order by idFilieres ASC"; 
$statement = $db->prepare($query);
$statement->execute($explode);
while($row=$statement->fetch(PDO::FETCH_ASSOC)){
	$json1['filieres'][]=$row;		
}

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