prepare('SELECT id, title, icon, items, position FROM skills ORDER BY position ASC, id ASC'); $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { return []; } } // Fonction qui permet de récupérer une catégorie de compétences par id (pour la modification dans le panel Admin) function recupererSkillParId($id) { global $dbh; try { $stmt = $dbh->prepare('SELECT id, title, icon, items, position FROM skills 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 de compétences (utilisée par la page publique et le panel admin) // Les items sont stockés un par ligne, au format "classes-icone|Texte" (icône optionnelle) function afficherSkillCard($skill, $admin = false) { $id = (int) $skill['id']; $titre = htmlspecialchars($skill['title']); $icone = htmlspecialchars(!empty($skill['icon']) ? $skill['icon'] : 'fa-solid fa-star'); echo '
'; echo '
'; echo '

' . $titre . '

'; echo ''; // Boutons de modification / suppression pour le panel admin if ($admin) { echo '
'; echo 'Modifier'; echo 'Supprimer'; echo '
'; } echo '
'; } // Fonction qui va afficher les compétences sur la page publique function afficherSkills() { $skills = listeSkills(); // Si la table est vide ou n'existe pas encore if (empty($skills)) { echo '

Les compétences seront bientôt disponibles.

'; return; } echo '
'; foreach ($skills as $skill) { afficherSkillCard($skill, false); } echo '
'; } // Fonction identique à celle en haut mais ajout de boutons pour le panel admin function afficherSkillsAdmin() { $skills = listeSkills(); echo '
'; foreach ($skills as $skill) { afficherSkillCard($skill, true); } echo '
'; }