Bonjour,
Je souhaite faire un catalogue produits, il faut donc que j'affiche pour chaque catégorie, le titre correspondant. Ceci dans un affichage page par page. Voici le code que j'ai réalisé mon probleme, c'est qu'il m'affiche plusieurs fois chaque titre et chaque produit. Voici le code correspondant (j'ai enlevé tout le code pour l'affichage page par page) :
$requete = "SELECT id, explication, dimension, prix, image,nom_categorie, pdf, nom_categorie FROM produits ORDER BY nom_categorie Limit $limite_mysql , $limite_page ";
$result = mysql_query($requete) or die ('Erreur : '.mysql_error() );
$Tab = array();
while($Tab[] = mysql_fetch_assoc($result));
$req = "SELECT id, nom_categorie FROM produits GROUP BY nom_categorie ";
$res = mysql_query($req) or die(mysql_error());
$nbc = mysql_numrows($res);
$requet = "SELECT count(id) AS nbprod, nom_categorie FROM produits GROUP BY nom_categorie ";
$resulta = mysql_query($requet) or die(mysql_error());
$tablo = array();
while($tablo[] = mysql_fetch_assoc($result));
while($j = mysql_fetch_assoc($res)){
for ($h=0 ; $h<count($tablo) ; $h++) {
if ($h<$limite_page){
echo '<br><div id=normal><table width=665><tr bgColor=#005291><td class=titre><b><i>'.$j['nom_categorie'].'</i></b></td></tr></font></table></div>';
echo '<div id=normal><table ><tr><td width=80 align=left class=entete>REFERENCE</td><td width=300 class=entete>DESIGNATION</td><td width=70 align=center class=entete>H x L x P</td><td width=50 align=right class=entete>€ H.T.</td></tr></table></div><div id=tableau><table cellSpacing=0 cellPadding=0 >';
// On affiche les produits de la premiere categorie
for($i=0 ; $i<count($Tab) ; $i++)
{
// Uniquement si les ID categories sont identiques
if($Tab[$i]['nom_categorie']==$j['nom_categorie']){
echo '<tr><td colspan="3" valign=top align=left width=80 bgColor=#CEE08B><div id=ref><a href="./fiches-produits.php?reference='.$Tab[$i]['id'].'"><b>'.$Tab[$i]['id'].'</b></a></div></td><td colspan="2" width=300 valign=top align=left class=ligne><div id="designation">'.$Tab[$i]['explication'].'</div></td><td colspan="2" width=80 class=ligne valign=top align=left><div id=designation>'.$Tab[$i]['dimension'].'</div></td><td colspan="3" width=40 class=prix valign=top align=right><div id=designation>'.$Tab[$i]['prix'].'</div></td><td class=ligne valign=top align=left><img border=0 src='.$Tab[$i]['image'].'></td><td valign=top align=left class=ligne><a href="IMAGE_CLIENT/PDF/'.$Tab[$i]['pdf'].'"><div id=designation><img border=0 src="IMAGE_CLIENT\pdf.jpg"></div></td></tr>'; }
}
echo '</table></div>';
}
}
}
?>