Condition IF pour afficher une ligne d'une table
Posté : 02 avr. 2021, 12:54
Bonjour
j'ai une datatable
Pour chaque enregistrement de ma table j'ai une colonne contenant des boutons permettant la modification ou la suppression.
J'aurai aimé ajouter un troisième bouton mais sous condition d'une valeur passé par une variable.
Mais cela ne marche pas. Pouvez vous m'éclairer? Merci
j'ai une erreur
j'ai une datatable
Code : Tout sélectionner
<table id='tab' class='display compact table-responsive'>
<thead>
<tr class="table-secondary text-dark">
<th width="1%">id</th>
<th width="1%">Logo</th>
<th width="1%">Fédérée</th>
<th width="30%">Nom long</th>
<th width="1%">Abréviation</th>
<th width="5%">Email</th>
<th width="1%">Téléphone</th>
<th width="2%">Actions</th>
<th width="2%"></th>
</tr>
</thead>
<tboby>
<?php
foreach ($result as $produit) {
?>
<tr>
<td><?php echo $produit['Id_Assos']; ?></td>
<td><?php echo "<img src='" . $produit['Logo_Reduit'] . "' />"; ?></td>
<td><?php echo $produit['Federe']; ?></td>
<td><?php echo $produit['Nom_Assos']; ?></td>
<td><?php echo $produit['Nom_Court']; ?></td>
<td><?php echo $produit['Email']; ?></td>
<td><?php echo $produit['Telephone']; ?></td>
<?php
$federe=$produit['Federe'];
if ($federe=Oui){
<td><a class=" btn btn-warning btn-sm" role="button" href="Nonfedere.php?Id_Assos=<?= $produit['Id_Assos']; ?>"> Fédéré=Non</a></td>;
elseif
<td><a class=" btn btn-warning btn-sm" role="button" href="Ouifedere.php?Id_Assos=<?= $produit['Id_Assos']; ?>"> Fédéré=Oui</a></td>
?>
<?php
}
?>
<td><a class=" btn btn-warning btn-sm" role="button" href="edit.php?Id_Assos=<?= $produit['Id_Assos']; ?>"><i class="far fa-edit"></i> Modifier</a></td>
<td><a class="btn btn-danger btn-sm" role="button" href="delete.php?Id_Assos= <?= $produit['Id_Assos']; ?>"><i class="far fa-trash-alt"></i>Supprimer</a></td>
</tr>
<?php
}
?>
</tboby>
<tfoot>
<tr class="table-secondary text-dark">
<th width="1%">id</th>
<th width="1%">Logo</th>
<th width="1%">Fédérée</th>
<th width="30%">Nom long</th>
<th width="1%">Abréviation</th>
<th width="5%">Email</th>
<th width="1%">Téléphone</th>
<th width="2%">Actions</th>
<th width="2%"></th>
</tr>
</tfoot>
</table>J'aurai aimé ajouter un troisième bouton mais sous condition d'une valeur passé par une variable.
Code : Tout sélectionner
<?php
$federe=$produit['Federe'];
if ($federe=Oui){
<td><a class=" btn btn-warning btn-sm" role="button" href="Nonfedere.php?Id_Assos=<?= $produit['Id_Assos']; ?>"> Fédéré=Non</a></td>;
elseif
<td><a class=" btn btn-warning btn-sm" role="button" href="Ouifedere.php?Id_Assos=<?= $produit['Id_Assos']; ?>"> Fédéré=Oui</a></td>
?>
<?php
}
?>j'ai une erreur
qui correspond à la ligne de mon premier <td> dans la condition IFParse error: syntax error, unexpected '<' in E:\FFMO\F_Entite\index.php on line 66