<?php
include "_serveur_json.php";
mysqli_set_charset($link, "utf8");

$classID = intval($_POST['classID'] ?? 0);
$subSubjectID = intval($_POST['subSubjectID'] ?? 0);
$coef = floatval($_POST['coef'] ?? 0);

if ($classID <= 0 || $subSubjectID <= 0) {
    echo "Paramètres invalides";
    exit;
}

// ✅ Make sure the column name matches your database (coeficient with one 'f')
$sql = "UPDATE gradesSubjects 
        SET coeficient = '$coef' 
        WHERE classID = '$classID' AND subSubjectID = '$subSubjectID'";

if (mysqli_query($link, $sql)) {
    echo "OK";
} else {
    echo "Erreur SQL: " . mysqli_error($link);
}
?>
