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
| <html>
<body>
<?php
session_start();
include("connexion.php");
connect($host,$user,$mot_passe,$db_name);
if ( !session_is_registered("authen_user")){
#echo '<META HTTP-EQUIV="refresh" CONTENT="0;URL=index.php?erreur=404">';
#redirection instantanée
header("location:index.php?erreur=404");
$select = SELECT id FROM pc ORDER BY id ASC LIMIT 50;
$result = mysql_query($select,$link) or die ('Erreur : '.mysql_error() );
$total = mysql_num_rows($result);
// si on a récupéré un résultat on l'affiche.
if($total) {
echo '<table bgcolor="#FFFFFF">'."\n";
echo '<td bgcolor="#669999"><b><u>id</u></b></td>';
echo '</tr>'."\n";
while($row = mysql_fetch_array($result)) {
echo '<tr>';
echo '<td bgcolor="#CCCCCC">'.$row['id'].'</td>';
echo '</tr>'."\n";
}
echo '</table>'."\n";
}
else echo 'Pas d\'enregistrements dans cette table...';
$nombre = 50; // on va afficher 50 résultats par page.
if (!isset($limite)) $limite = 0; .
$path_parts = pathinfo($_SERVER['PHP_SELF']);
$page = $path_parts['id'];
// initialisation des variable suivant et précédent
$limitesuivante = $limite + $nombre;
$limiteprecedente = $limite - $nombre;
// button "précedent"
if($limite != 0) {
echo '<form action="'.$page.'" method="post">';
echo '<input type="submit" value="précédents">';
echo '<input type="hidden" value="'.$limiteprecedente.'" name="limite">';
echo '</form>';
}
//button" suivant"
if($limitesuivante < $total) {
echo '<form action="'.$page.'" method="post">';
echo '<input type="submit" value="suivants">';
echo '<input type="hidden" value="'.$limitesuivante.'" name="limite">';
echo '</form>';
}
}
?>
</body>
</html> |
Partager