<?php

require_once '../../../config.php';

$conn = getDBConnection();



$response = ['success' => false, 'message' => ''];



$id = intval($_POST['id'] ?? 0);



if (!$id) {

    $response['message'] = 'Invalid subject ID';

    echo json_encode($response);

    exit;

}



// Delete the class subject

$stmt = $conn->prepare("DELETE FROM class_subjects WHERE id = ?");

$stmt->bind_param("i", $id);



if ($stmt->execute()) {

    $response['success'] = true;

    $response['message'] = 'Subject removed successfully';

} else {

    $response['message'] = 'Database error: ' . $stmt->error;

}



$stmt->close();

$conn->close();



echo json_encode($response);