Citation :
<html>
<head>
<title>Bienvenue sur mon site</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
a
{
background-color:bef7fb; color:00adef; text-align:left; font-family:verdana,Arial,Helvetica,Sans-serif; font-size:11px; text-decoration:none; border:1px ; margin:1px; padding:1px;
}
a:hover
{
background-color:bef7fb; color:a5ae51; font-weight:bold;
text-align:left;
}
p
{
font-family: verdana,Arial,Helvetica,Sans-serif; font-size: 11px; color:626262; bgcolor:ffffff; text-decoration:none; }
.text { font-family: Arial, Helvetica, sans-serif; font-size: 11px; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; text-transform: none; color: #535252}
.pagination a {color: black;}
.pagination a:hover {color: red; text-decoration: none;}
.pagination a:visited {color: red; text-decoration: none;}
</style>
</head>
<body bgcolor="#bef7fb" text="#535252">
<?
$host = "XXX";
$user = "XXX";
$pass = "XXX";
$data = "XXX"; $connect = mysql_connect($host, $user, $pass)
or die("Connexion au serveur impossible !" );
$db = mysql_select_db($data, $connect)
or die("Sélection de la base impossible !" );
$table = "news"; $champ = "id"; $sql = "SELECT * FROM news"; $parpage = 5; $url = $_SERVER['PHP_SELF']."?limit=";
$total = mysql_query($sql); $nblignes = mysql_num_rows($total);
$nbpages = ceil($nblignes/$parpage);
$result = validlimit($nblignes,$parpage,$sql);
while ($donnees = mysql_fetch_array($result))
//C'est ici que mes news s'affichent
{
?>
<p class="text">
<div style="font-family:Century Gothic; font-size: 16px; margin-bottom:1px; font-style: normal; line-height: normal; font-weight: normal; font-variant: small-caps; text-transform: none; color:ff00f6; border-bottom:1pt #ff00f6 solid">
<?php echo $donnees['titre']; ?>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 11px; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; text-transform: none; text-align:justify; padding:3px; margin-top:5px; margin-bottom:30px; color:535252">
<?php
$contenu = nl2br(stripslashes($donnees['contenu']));
echo $contenu;
?><br>
</div>
<?php
}
echo "<div class='pagination'>";
echo '<p align="center">Page : ';
echo pagination($url,$parpage,$nblignes,$nbpages);
echo '</p>';
echo "</div>";
mysql_free_result($result);
function pagination($url,$parpage,$nblignes,$nbpages)
{
$html = precedent($url,$parpage,$nblignes); if ($nbpages > 1) {
for ($i = 0 ; $i < $nbpages ; ++$i) {
$limit = $i * $parpage;
$limit = $limit.",".$parpage; $html .= "<a href=".$url.$limit.">".($i + 1)."</a> | " ;
}
}
else {
$html .= "";
}
$html .= suivant($url,$parpage,$nblignes); return $html;
}
function validlimit($nblignes,$parpage,$sql)
{
if (isset($_GET['limit'])) {
$pointer = split('[,]', $_GET['limit']); $debut = $pointer[0];
$fin = $pointer[1];
if (($debut >= 0) && ($debut < $nblignes) && ($fin == $parpage)) {
$limit = $_GET['limit'];
$sql .= " LIMIT ".$limit.";"; $result = mysql_query($sql); }
else {
$sql .= " LIMIT 0,".$parpage.";"; $result = mysql_query($sql); }
}
else {
$sql .= " LIMIT 0,".$parpage.";"; $result = mysql_query($sql);
}
return $result;
}
function precedent($url,$parpage,$nblignes)
{
if ($nblignes > $parpage) {
if (isset($_GET['limit'])) {
$pointer = split('[,]', $_GET['limit']);
$pointer = $pointer[0]-$parpage;
if ($pointer < 0) {
$precedent = "";
}
else {
$limit = "$pointer,$parpage";
$precedent = "<a href=".$url.$limit."><</a> | ";
}
}
else {
$precedent = ""; }
}
else {
$precedent = ""; }
return $precedent;
}
function suivant($url,$parpage,$nblignes)
{
if ($nblignes > $parpage) {
if (isset($_GET['limit'])) {
$pointer = split('[,]', $_GET['limit']);
$pointer = $pointer[0] + $parpage;
if ($pointer >= $nblignes) {
$suivant = "";
}
else {
$limit = "$pointer,$parpage";
$suivant = "<a class='pagination' href=".$url.$limit.">></a>";
}
}
if (@$_GET['limit']== false) {
$suivant = "<a href=".$url.$parpage.",".$parpage.">></a>";
}
}
else {
$suivant = ""; }
return $suivant;
}
?> </body>
</html>
|