<?php
session_start();
include '../includes/auth_admin.php';
include '../includes/db.php';

$data = json_decode(file_get_contents("php://input"), true);
if (!is_array($data)) {
    http_response_code(400);
    echo "Invalid data.";
    exit;
}

foreach ($data as $item) {
    $stmt = $pdo->prepare("UPDATE event_participants SET sort_order = ? WHERE id = ?");
    $stmt->execute([$item['sort'], $item['id']]);
}

echo "Sort order updated.";
?>
