<?php
require_once '../config/db.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['id'], $_POST['toggle'])) {
    $id = intval($_POST['id']);
    $afficher = $_POST['toggle'] == '1' ? 1 : 0;
    $db = getDbConnection();
    $stmt = $db->prepare('UPDATE telechargements SET afficher = ? WHERE id = ?');
    $stmt->execute([$afficher, $id]);
}
header('Location: admin-liste-telechargements.php');
exit;
