1 pièce(s) jointe(s)
afficher les colonnes d'une table qui est dans une BDD
Bonjour,
Je souhaite afficher les noms des colonnes d'une table, si possible en tableaux HTML. Je ne vois pas comment faire, pouvez-vous m'aider ?
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 66 67 68 69 70 71 72 73 74 75 76 77
| <html>
<head><title>Liste des capteurs </title></head>
<link href="css/" rel="stylesheet" media="all" type="text/css"/>
<body>
<h1>Liste des capteurs : </h1>
<form name="connexion" method="post">
</br>
</br>
Choisir un capteur
<select name="Capteur">
<?php
for ($i=1;$i<30;$i++)
{
echo "<option>capteur ".$i."</option>";
}
?>
</select>
</br>
</br>
<input type="submit" name="valider" value="OK"/>
<input type='submit' name='annuler' value='ANNULER'/>
</br>
</br>
</form>
<?php
if (isset($_POST['valider']))
{
// on se connecte à MySQL et on sélectionne la base
$conn = new mysqli('localhost', 'root', '', 'air_exterieur');
if ($conn->connect_errno)
{
echo "Echec lors de la connexion à MySQL : " . $conn->connect_error;
}
// On créé la requête
$nbBoitierChaine = substr ($_POST['Capteur'] ,8);
//echo $nbBoitierChaine;
$nbBoitier = intval($nbBoitierChaine);
$req = "SELECT * FROM boitier_qae WHERE Num_boitiers=".$nbBoitier." ORDER BY Num_boitiers";
//echo $req;
// on envoie la requête
$res = $conn->query($req);
// on va scanner tous les tuples un par un
echo "<table class='paleBlueRows' >";
while($data = mysqli_fetch_array($res))
{
// on affiche les résultats
echo "<tr>
<td>".$data['Num_boitiers']."</td>
<td>".$data['Date_Heure']."</td>
<td>".$data['PM0_3']."</td>
<td>".$data['PM0_5']."</td>
<td>".$data['PM1']."</td>
<td>".$data['PM2_5']."</td>
<td>".$data['PM5']."</td>
<td>".$data['PM10']."</td>
<td>".$data['Latitude']."</td>
<td>".$data['Longitude']."</td>";
echo "</tr>" ;
}
echo "</table>";
// on ferme la connexion
$conn->close();
}
?>
</body>
</html> |
c'est la ligne commençant par 2 qui contient toute les information.
Merci d'avance pour vos réponse
Baptiste