Code : Tout sélectionner
<?php
mysql_connect($host, $user, $password) or die ("Erreur de connexion à la base sql :/");
mysql_select_db('livredor_db') or die ("Impossible de trouver la BDD");
$query = mysql_query("SELECT count(id) FROM livredor");
$row = mysql_fetch_row($query);
$total = $row[0];
$nombre = "5";
if (isset($_GET['limite']) && is_numeric($_GET['limite']) && $_GET['limite'] + $nombre < $total){
$limite = $_GET['limite'];
$suivant = $limite + $nombre;
echo '<a href="'.$_SERVER['PHP_SELF'].'?limite='.$suivant.'">Suivant</a>';
}
if (isset($_GET['limite']) && is_numeric($_GET['limite']) && $_GET['limite'] != 0){
$limite = $_GET['limite'];
$precedant = $limite - $nombre;
echo '<a href="'.$_SERVER['PHP_SELF'].'?limite='.$precedant.'">Precedant</a>';
}
if (!isset($_GET['limite'])){
$limite = 0;
$suivant = $limite + $nombre;
echo '<a href="'.$_SERVER['PHP_SELF'].'?limite='.$suivant.'">Suivant</a>';
}
if ($total){
$query = mysql_query("SELECT * FROM livredor ORDER BY id DESC LIMIT $limite, $nombre");
echo '<table width="900" border="0" cellspacing="1" cellpadding="0" align="center">';
while ($array = mysql_fetch_array($query)){
echo '<tr>
<td width="900">Commentaire n°'.$array['id'].'</td>
</tr>
<tr>
<td widht="900">
<table width="900" border="0" cellspacing="0" cellpading="0">
<tr>
<td width="150">Nom : '.$array['pseudo'].'</td>
<td width="750">Mail : '.$array['mail'].'</td>
</tr>
</table>
</td>
<tr>
<td width="900">Message : '.$array['message'].'</td>
</tr>
<tr>
<td height="15"></td>
</tr>';
}
echo '</table>';
}
else{
echo 'Aucune entrée';
}
mysql_free_result($query);