Julien30580Le 27/08/2013 à 10:41
Bonjour Et merci de votre réponse.
Dans la théorie c'est un peu ce que j'avais imaginer.
Mais dans la pratique, je suis pas sûr de savoir comment faire.
J'ai commencer quelque chose, mais je crois que je fait fausse route.
voici ou j'en suis :
<?php
//récupération de $limite
if(isset($_GET['limite']))
$limite=$_GET['limite'];
else $limite=0;
function verifLimite($limite,$total,$nombre) {
// je verifie si limite est un nombre.
if(is_numeric($limite)) {
// si $limite est entre 0 et $total, $limite est ok
// sinon $limite n'est pas valide.
if(($limite >=0) && ($limite <= $total) && (($limite%$nombre)==0)) {
// j'assigne 1 à $valide si $limite est entre 0 et $max
$valide = 1;
}
else {
// sinon j'assigne 0 à $valide
$valide = 0;
}
}
else {
// si $limite n'est pas numérique j'assigne 0 à $valide
$valide = 0;
}
// je renvois $valide
return $valide;
}
$nombre = 2; // on va afficher 2 résultats par page.
if (!isset($limite)) $limite = 0; // si on arrive sur la page pour la première fois
// on met limite à 0.
$path_parts = pathinfo($_SERVER['PHP_SELF']);
$page = $path_parts['basename'];
$db = mysql_connect('localhost', 'root', '');
mysql_select_db('***',$db);
$select = "SELECT count(id) FROM produit WHERE active='1'";
$result = mysql_query($select) or die ('Erreur : '.mysql_error() );
$row = mysql_fetch_row($result);
$total = $row[0];
$sql = "SELECT * FROM produit WHERE active='1' ORDER BY sousouscategorie ASC LIMIT $limite,$nombre";
$req=mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
while($data = mysql_fetch_assoc($req))
{
// on affiche les informations de l'enregistrement en cours
$id=$data['id'];
$nom=$data['nom'];
$plan=$data['plan'];
$categorie=$data['sousouscategorie'];
$categorie = mb_strtoupper($categorie, 'UTF-8');
$limitesuivante = $limite + $nombre;
?>
<style type="text/css">
table.page_header {width: 100%; border: none; background-color: #e1e1e1; border-bottom: solid 1mm #bcbcbc; padding: 2mm }
table.page_footer {width: 100%; border: none; background-color: #e1e1e1; border-top: solid 1mm #bcbcbc; padding: 2mm}
h3.note {border: solid 1mm #DDDDDD;background-color: #EEEEEE; padding: 2mm; border-radius: 2mm; width: 100%; }
ul.main { width: 95%; list-style-type: square; }
ul.main li { padding-bottom: 2mm; }
h1 {text-align: center; font-size: 20mm}
h3 {text-align: center; font-size: 12mm}
h5 {letter-spacing: 10px; text-align: center; font-size: 8mm}
</style>
<table>
<tr><td><h3 class="note"> <?php echo $id ;?> </h3></td></tr>
</table>
<table style="border-collapse:collapse;"border="1" align="center" width="100%">
<tr>
<td height=250 width=350 align="center">
<?php echo "<img width=\"200\" height=\"200\" src=\"imageProduits/$id.jpg\">"; ?>
</td>
<?php if (!empty($plan))
{
echo "<td height=250 width=350 align=\"center\"><img width=\"200\" height=\"200\" src=\"imageProduits/$id-zoom.jpg\"></td>";
}
?>
</tr>
</table>
<table width=100%>
<tr>
<td><h4><?php $Nom=str_replace ("***","Réf :","$nom"); echo $Nom; ?></h4></td>
</tr>
</table><hr>
pouvez vous me mettre sur la bonne piste?
Merci