prepare('SELECT id, title, status, tags, description, duration, image_url FROM schools ORDER BY id DESC');
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
return [];
}
}
// Fonction qui permet de récupérer une école par id (pour la modification dans le panel Admin)
function recupererEcoleParId($id) {
global $dbh;
try {
$stmt = $dbh->prepare('SELECT id, title, status, tags, description, duration, image_url FROM schools WHERE id = :id');
$stmt->bindValue(':id', $id, PDO::PARAM_INT);
$stmt->execute();
return $stmt->fetch(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
return false;
}
}
// Fonction interne qui affiche une carte école (utilisée par la page publique et le panel admin)
function afficherEcoleCard($ecole, $admin = false) {
$id = (int) $ecole['id'];
$titre = htmlspecialchars($ecole['title']);
$description = nl2br(htmlspecialchars($ecole['description']));
$duration = htmlspecialchars($ecole['duration']);
$image = htmlspecialchars($ecole['image_url']);
$status = htmlspecialchars($ecole['status'] ?? '');
$tags = [];
// S'il y a des tags alors on les sépares grâce à la virgule (tags1,tags2,etc...)
if (!empty($ecole['tags'])) {
$tags = array_filter(array_map('trim', explode(',', $ecole['tags'])));
}
echo '