par
53pierre » 11 mars 2021, 12:01
j ai essaye en mettant une condition dans la requete mais cela ne semble pas fonctionner
Code : Tout sélectionner
$resultat = $mysqli->query("SELECT pseudo, message, DATE_FORMAT(date_enregistrement, '%d/%m/%Y') AS datefr, DATE_FORMAT(date_enregistrement, '%H:%i:%s') AS heurefr FROM commentaire WHERE valider = 1 ORDER BY date_enregistrement DESC");
$contenu .= '<h2>' . $resultat->num_rows . ' commentaire(s)';
?>
<div class="commentaire"><?php echo $contenu; ?></div>
<div id="logo">
</div>
<h1> Sorties de pêche</h1>
<nav>
<a href="?page=<?= $currentPage - 1 ?>" class="page-link">Précédente</a>
<?php for($page = 1; $page <= $pages; $page++): ?>
<a href="?page=<?= $page ?>" class="page-link"><?= $page ?></a>
<?php endfor ?>
<?= ($currentPage == $pages) ? "disabled" : "" ?>
<a href="?page=<?= $currentPage + 1 ?>" class="page-link">Suivante</a>
</nav>
<table class="t1">
<thead>
<th width=25%> pseudo</th>
<th width=25% > message </th>
<th width=25%>date enregistrement </th>
<th width=25%>valider </th>
</thead>
</table>
<table class="t2">
<?php
foreach($crud as $commentaire){
?>
<tr>
<td width=25%><?= $commentaire['pseudo'] ?></td>
<td width=25%><?= $commentaire['message'] ?></td>
<td width=25%><?= $commentaire['date_enregistrement'] ?></td>
<td width=25%><?= $commentaire['valider'] ?></td>
</tr>
<?php
}
?>
</table>
j ai essaye en mettant une condition dans la requete mais cela ne semble pas fonctionner
[code]$resultat = $mysqli->query("SELECT pseudo, message, DATE_FORMAT(date_enregistrement, '%d/%m/%Y') AS datefr, DATE_FORMAT(date_enregistrement, '%H:%i:%s') AS heurefr FROM commentaire WHERE valider = 1 ORDER BY date_enregistrement DESC");
$contenu .= '<h2>' . $resultat->num_rows . ' commentaire(s)';
?>
<div class="commentaire"><?php echo $contenu; ?></div>
<div id="logo">
</div>
<h1> Sorties de pêche</h1>
<nav>
<a href="?page=<?= $currentPage - 1 ?>" class="page-link">Précédente</a>
<?php for($page = 1; $page <= $pages; $page++): ?>
<a href="?page=<?= $page ?>" class="page-link"><?= $page ?></a>
<?php endfor ?>
<?= ($currentPage == $pages) ? "disabled" : "" ?>
<a href="?page=<?= $currentPage + 1 ?>" class="page-link">Suivante</a>
</nav>
<table class="t1">
<thead>
<th width=25%> pseudo</th>
<th width=25% > message </th>
<th width=25%>date enregistrement </th>
<th width=25%>valider </th>
</thead>
</table>
<table class="t2">
<?php
foreach($crud as $commentaire){
?>
<tr>
<td width=25%><?= $commentaire['pseudo'] ?></td>
<td width=25%><?= $commentaire['message'] ?></td>
<td width=25%><?= $commentaire['date_enregistrement'] ?></td>
<td width=25%><?= $commentaire['valider'] ?></td>
</tr>
<?php
}
?>
</table>[/code]