La ou j'ai des difficultés c'est au niveau de la premiere ligne qui contien les noms des colonnes , je sais pas comment mettre cette ligne dans mon tableau aidez moi .
merci d'avance
Code : Tout sélectionner
<html>
<head>
<style type="text/css">
#arriere_plan {
width:400px;
height:147px;
background:bdfdcc;
margin-left:400px;
margin-top:100px;
}
table
{
border-collapse: collapse;
}
caption
{
font-family:verdana;
font-size:18;
caption-side:top;
}
th
{
border: 2px solid black;
background:c0f4cc;
font-family:verdana;
font-size:15;
}
td
{
border: 2px solid black;
background:c0f4cc;
font-family:verdana;
font-size:15;
}
tr
{
border: 2px solid black;
background:c0f4cc;
font-family:verdana;
font-size:15;
}
</style>
</head>
<body>
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=productions','root','',array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
?>
<thead>
</thead>
<tbody>
<caption>Liste des fruits </caption>
<br/>
<tr>
<th>Fruit</th>
<th>Saison</th>
<th>Prix</th>
</tr>
</tbody>
<?php
$reponse = $bdd->query('SELECT * FROM fruits');
$ortie = '<table border="1" width="400">'.chr(13);
while ($donnees = $reponse->fetch())
{
$ortie.= '<tr>'.chr(15);
$ortie.= ' <td>'.$donnees['nom'].'</td>'.chr(15);
$ortie.= ' <td>'.$donnees['saison'].'</td>'.chr(15);
$ortie.= ' <td>'.$donnees['prix'].'</td>'.chr(15);
$ortie.= '</tr>'.chr(15);
}
$ortie.='</table>';
echo $ortie;
$reponse->closeCursor(); // Termine le traitement de la requête
?>
</div>
</body></html>