<?php 
session_start();
require_once(dirname(__DIR__, 2) . '/config.php');
require_once(BASE_PATH . '/db/idl_connect.php');
if(isset($_SESSION['user_droits'])) {
	$eleve = $_REQUEST['eleve'];
	$note = $_REQUEST['note'];
	foreach($_REQUEST as $key => $value) {
		if($value!=$eleve&&$value!=$note) {
			$eval_verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_savele WHERE eleves_id = '".$eleve."' AND s_id = '".$value."'"));
			if($eval_verif_nb==1) {
				mysqli_query($bdd,"UPDATE ".$prefix."_savele SET eval = '".$note."' WHERE eleves_id = '".$eleve."' AND s_id = '".$value."'");
			}
			else if($eval_verif_nb==0) {
				mysqli_query($bdd,"INSERT INTO ".$prefix."_savele (eleves_id, s_id, eval) VALUES ('".$eleve."', '".$value."', '".$note."')");
			}
		}
	}
}
mysqli_close($bdd);
?>