Untitled
unknown
plain_text
2 years ago
3.2 kB
8
Indexable
<?php
// Connexion à la base de données (à adapter avec vos propres informations)
$serveur = "localhost";
$utilisateur = "root";
$motDePasse = "";
$baseDeDonnees = "formation";
try {
$database = new PDO("mysql:host=$serveur;dbname=$baseDeDonnees", $utilisateur, $motDePasse);
$database->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
die("La connexion à la base de données a échoué : " . $e->getMessage());
}
// Récupération des formateurs depuis la base de données
$requeteCours = $database->query("SELECT * FROM cours");
$listeCours = $requeteCours->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Liste des Cours</title>
<!-- Ajoutez le lien vers votre fichier CSS ici -->
<link rel="stylesheet" href="affichage.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<h1>Liste des Cours</h1>
<h2>Contenu principal</h2>
<!-- Affichage du tableau des formateurs -->
<table border="1">
<thead>
<tr>
<th>ID Cours</th>
<th>Titre</th>
<th>Date Debut</th>
<th>Date Fin</th>
<th>Voir Cours</th>
<th>Modification</th>
<th>Suppression</th>
</tr>
</thead>
<tbody>
<?php foreach ($listeCours as $cours) : ?>
<tr>
<td><?= $cours['IDCO'] ?></td>
<td><?= $cours['titreCO'] ?></td>
<td><?= $cours['datedebutCO'] ?></td>
<td><?= $cours['datefinCO'] ?></td>
<td>
<form action="//localhost/test%20web/cours/<?php echo $cours['nomC']; ?>" method="get">
<input type="hidden" name="IDCO" value="<?php echo $cours['IDCO']; ?>">
<button type="submit">Afficher</button>
</form>
</td>
<td>
<form action="//localhost/test%20web/modifierc.php" method="get">
<input type="hidden" name="IDCO" value="<?php echo $cours['IDCO']; ?>">
<button type="submit" class="btn btn-primary">modifier</button>
</form>
</td>
<td>
<form action="//localhost/test%20web/supprimerc.php" method="get" onsubmit="return confirm('Êtes-vous sûr de vouloir supprimer ce cours ?')">
<input type="hidden" name="IDCO" value="<?php echo $cours['IDCO']; ?>">
<button type="submit" class="btn btn-danger">supprimer</button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>Editor is loading...
Leave a Comment