From bcf8a27a04f7e7423eded805a2e594f9b0d09f80 Mon Sep 17 00:00:00 2001 From: Esteban Date: Wed, 3 Jun 2026 16:29:05 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20l'affichage=20des=20projets=20gr?= =?UTF-8?q?=C3=A2ce=20=C3=A0=20une=20requ=C3=AAte=20SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/listProject.php | 82 ++++++++++++++++++++++++++++++++------- pages/projects.php | 8 +++- styles/primary_css.css | 77 ++++++++++++++++++++++++++++++++++-- 3 files changed, 147 insertions(+), 20 deletions(-) diff --git a/functions/listProject.php b/functions/listProject.php index df03a4d..42422e7 100644 --- a/functions/listProject.php +++ b/functions/listProject.php @@ -1,23 +1,77 @@ prepare('SELECT * FROM projects'); + // Essayer + try { + // Requête SQL qui récupère titre, tags, description, image_url + $stmt = $dbh->prepare('SELECT title, tags, description, image_url FROM projects'); + // Execution de la requête SQL + $stmt->execute(); + // Retourne toutes les données collectés dans un ARRAY + return $stmt->fetchAll(PDO::FETCH_ASSOC); + } catch (PDOException $e) { // En cas d'erreur + die("Erreur de connexion à la base de donnée portfolio :".$e->getMessage()); + return []; + } +} - // Execution de la requête - $stmt->execute(); - // On pourra même prévoir plus tard grâce à cette requête préparer d'ajouter des filtrages pour la liste (ex : En cours/Défjà fini etc...) +// Fonction qui va afficher les projets +function afficherProjets() { + // Récupération de la liste des projets + $projets = listeProjets(); - // On sauvegarde les données renvoyées - $donneerenvoyee = $stmt->fetch(); + // Ajout de la class pour la liste des projets FUTUR CSS + echo '
'; - // Puis on les renvoies - return $donneerenvoyee; + + // Pour chaque projet dans le ARRAY + foreach ($projets as $projet) { + // On récupère le titre, la description et l'image et le tableau avec les tags + $titre = htmlspecialchars($projet['title']); + $description = nl2br(htmlspecialchars($projet['description'])); + $image = htmlspecialchars($projet['image_url']); + $tags = []; + + // S'il y a des tags alors on les sépares grâce à la virgule que l'user à ajouté dans le champs (tags1,tags2,etcc...) + if (!empty($projet['tags'])) { + $tags = array_filter(array_map('trim', explode(',', $projet['tags']))); + } + + echo '
'; + + // Si la donnée avec l'image n'est pas null alors on l'affiche + if (!empty($image)) { + echo '
'; + echo 'Image du projet ' . $titre . ''; + echo '
'; + } + + // Ajout de la class project-content et du titre + echo '
'; + echo '

' . $titre . '

'; + + // Si les tags ne sont pas vides alors afficher + if (!empty($tags)) { + echo '
'; + foreach ($tags as $tag) { + echo '' . htmlspecialchars($tag) . ''; + } + echo '
'; + } + + // Ajout de la description et fin des classes + echo '

' . $description . '

'; + echo '
'; + + echo '
'; + } + + echo '
'; } \ No newline at end of file diff --git a/pages/projects.php b/pages/projects.php index c59da1d..14e9cdf 100644 --- a/pages/projects.php +++ b/pages/projects.php @@ -16,7 +16,7 @@ if (isset($_SESSION['role']) && $_SESSION['role'] === 'admin') { ?>
-
+

Nouveau projet

@@ -50,9 +50,13 @@ if (isset($_SESSION['role']) && $_SESSION['role'] === 'admin') { ?> // Affichages des projets ?> -

Liste des projets

+

Liste des projets

\ No newline at end of file diff --git a/styles/primary_css.css b/styles/primary_css.css index 25c0543..b46fabd 100644 --- a/styles/primary_css.css +++ b/styles/primary_css.css @@ -120,7 +120,7 @@ nav a { padding: 40px 20px; } -.project-card { +.project-form-card { background-color: #111116; /* Fond très sombre comme sur l'image */ border: 1px dashed #3a3a5e; /* Bordure pointillée */ border-radius: 12px; @@ -164,9 +164,9 @@ nav a { } /* Inputs reprenant ton style login */ -.project-card input[type="text"], -.project-card input[type="url"], -.project-card textarea { +.project-form-card input[type="text"], +.project-form-card input[type="url"], +.project-form-card textarea { width: 100%; background-color: #1a1a24; border: 1px solid #2a2a3e; @@ -209,4 +209,73 @@ nav a { .btn-submit:hover { background-color: #5a52e0; +} + +.projects-title { + color: white; + font-size: 22px; + font-weight: bold; + margin: 0; + padding: 0 40px 20px 40px; +} + +.projects-list { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); + gap: 24px; + padding: 0 40px 40px 40px; +} + +.projects-list .project-card { + background-color: #111116; + border: 1px solid #2a2a3e; + border-radius: 16px; + overflow: hidden; + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); + transition: transform 0.2s ease, box-shadow 0.2s ease; +} + +.projects-list .project-card:hover { + transform: translateY(-4px); + box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35); +} + +.project-banner img { + width: 100%; + height: 220px; + object-fit: cover; + display: block; +} + +.project-content { + padding: 20px; +} + +.project-content h2 { + margin: 0 0 12px; + font-size: 22px; + color: white; +} + +.project-content p { + margin: 0; + color: #b8b8c7; + line-height: 1.6; +} + +.project-tags { + display: flex; + flex-wrap: wrap; + gap: 10px; + margin-bottom: 16px; +} + +.tag { + background-color: rgba(108, 99, 255, 0.15); + color: #8f88ff; + border: 1px solid rgba(108, 99, 255, 0.35); + padding: 6px 12px; + border-radius: 999px; + font-size: 13px; + font-weight: bold; } \ No newline at end of file