start(); /// TODO try to remove them if possible include_once (GLPI_ROOT . "/inc/db.function.php"); // Standard includes include_once (GLPI_ROOT . "/inc/config.php"); //disbled errors =>pour le variable res (Ajax) ini_set('display_errors', 0); Session::checkLoginUser(); global $DB; function getUsersScores($year){ global $DB; $query = "SELECT * FROM `resultat_eval_scores` WHERE type_id = ? "; $stmt = $DB->prepare($query); $stmt->bind_param("i" , $year); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { $res = array(); while($row = $result->fetch_assoc()){ $res[$row['user_id']] = array($row['score'],$row['id_rfe']); } return $res; } return []; } if(isset($_POST)){ switch ($_GET['action']) { case "get_utilisateur_scores": $scores = getUsersScores($_GET['year']); echo json_encode($scores); break; } }