1 pièce(s) jointe(s)
[PHP/SQL] Insérer les données de la BDD dans un tableau
bonsoir,
j'aimerais mettre les données récupérés depuis la BDD dans un tableau simple. Comment ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
<?php
try{
$objetPDO = new PDO('mysql:host=localhost;dbname=netflix','root','root',
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false
]);
$stmt = $objetPDO->prepare('SELECT * FROM series ORDER BY nomserie ASC');
$stmt->execute();
$series = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (Exception $e) {
echo "ERREUR : ".$e->getMessage()."\n";
}
?> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
<!DOCTYPE html>
<html>
<head>
<title>Séries Netflix</title>
<link rel="stylesheet" href="styleaff.css">
<div id="conteneur">
<nav>
<ul id="menu">
<li><a href="acceuil.html">Acceuil</a></li>
<li><a href="index.html">Formulaire</a></li>
<li><a href="affichagenetflix.php">Séries Vus</a></li>
<li><a href="https://www.netflix.com/browse">Site de Netflix</a></li>
</ul>
</nav>
</div>
</head>
<body>
<b>
<p> NOM SAISON EPISODE </p>
<ul>
<?php foreach ($series as $serie): ?>
<li>
<?php echo $serie['nomserie']." ".$serie['Saison']." ".$serie['Episode'] ?> <a href="supprimer.php?numSerie=<?=$serie['nomserie']?>">Supprimer</a>
<a href="modifier.php?numSerie=<?=$serie['nomserie']?>">Modifier</a>
</li>
<?php endforeach; ?>
</ul>
</b>
<CENTER>
<table class="tabcenter">
<caption> <font size="6"<strong><p style="color : black " >Liste des séries Netflix : </</caption></strong></font></p>
<tr>
<th><p style="color : #FF0000;" > Nom de la Série</th>
<th><p style="color : #FF0000;" > Saison</th>
<th><p style="color : #FF0000;" > Episode</th>
</p>
</tr>
<tr>
<td><p style="color : blue;" > <?php echo $serie['nomserie'] ?> </td>
<td><p style="color : blue;" > <?php echo $serie['Saison'] ?></td>
<td><p style="color : blue;" > <?php echo $serie['Episode'] ?></td>
</p>
</tr>
</table>
</CENTER>
</body>
</html> |
Pièce jointe 518040