Problèmes affichage avec tableau
Bonjour,
J’ai un soucis dans mon code qui n’affiche pas les données de ma variable $name dans mon tableau html.
Et mon tableau est tout simplement inexistant donc même les entêtes ne s’affiche pas et cela sans raisons !
Le code de la page contenant le tableau :
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
| <?php
require('conditions.php');
?>
<div class="employees">
<table>
<thead>
<tr>
<?php
if ($all['fonction'] == "1") {
echo '<th>Pharmaciens</th>';
}
if ($all['fonction'] == "2") {
echo '<th>Préparateurs/trices</th>';
}
if ($all['fonction'] == "3") {
echo '<th>Fonction1</th>';
}
if ($all['fonction'] == "4") {
echo '<th>Secrétaires</th>';
}
if ($all['fonction'] == "5") {
echo '<th>Agents dentretien</th>';
}
?>
</tr>
</thead>
<tbody>
<tr>
<?php
if ($all['fonction'] == "1") {
echo '<td>'. $pharmaciens['name'] .'</td>';
}
if ($all['fonction'] == "2") {
echo '<td>'. $preparateurs['name'] .'</td>';
}
if ($all['fonction'] == "3") {
echo '<td>'. $fonction1['name'] .'</td>';
}
if ($all['fonction'] == "4") {
echo '<td>'. $secretaires['name'] .'</td>';
}
if ($all['fonction'] == "5") {
echo '<td>'. $agents['name'] .'</td>';
}
?>
</tr>
</tbody>
</table>
</div> |
Voici le code de la page conditions.php :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <?php
$bdd = new PDO('mysql:host=localhost;dbname=Dbname', 'user', 'pass');
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$reqall= $bdd->prepare('SELECT * FROM employees');
$all = $reqall->fetch();
$reqpharmaciens= $bdd->prepare('SELECT * FROM employees WHERE fonction = "1" ');
$pharmaciens = $reqpharmaciens->fetch();
$reqpreparateurs= $bdd->prepare('SELECT * FROM employees WHERE fonction = "2" ');
$preparateurs = $reqpreparateurs->fetch();
$reqsecretaires= $bdd->prepare('SELECT * FROM employees WHERE fonction = "3" ');
$secretaires = $reqsecretaires->fetch();
$reqfonction1= $bdd->prepare('SELECT * FROM employees WHERE fonction = "4" ');
$fonction1 = $reqfonction1->fetch();
$reqagents= $bdd->prepare('SELECT * FROM employees WHERE fonction = "5" ');
$agents = $reqagents->fetch();
?> |
Merci d’avance pour votre aide ;)