Voilà le topo : J'ai une table contenant des nom de logiciel ainsi qu'un entier correspondant a leur categorie. J'ai une deuxieme table qui regroupe justement les categories. L'id d'un categorie correspond donc avec l'entier de la table logiciel. J'espere que vous me suivez...
Je veut donc obtenir le resultat suivant :
Le titre de la categorie, les logiciels qui y sont associés, et ainsi dessuite. J'ai donc fait ceci :
Code : Tout sélectionner
<?php
// SELECTION CATEGORIE LOGICIEL
$sql= "SELECT id_categ, nom_categ FROM logiciels_categ ORDER BY order_categ";
$req= mysql_query($sql) or die ('Erreur : '.$sql.'<br .>'.mysql_error());
// SELECTION LOGICIEL
$sql2= "SELECT id_logiciel, nom_logiciel, categ_logiciel FROM logiciels_logiciels ORDER BY nom_logiciel";
$req2= mysql_query($sql2) or die ('Erreur : '.$sql2.'<br .>'.mysql_error());
// BOUCLE
while ($data= mysql_fetch_assoc($req)) {
echo '<h2>'.$data['nom_categ'].'</h2>'; // AFFICHAGE CATEGORIE
while ($data2= mysql_fetch_assoc($req2)) { // BOUCLE 2
if ($data['id_categ'] == $data2['categ_logiciel']) { // SI VARIABLE CATEGORIE EGAL VARIABLE CATEGORIE LOGICIEL
echo '<h3>'.$data2['nom_logiciel'].'</h3>';
}
}
}
?>
Voilà j'espere que vous pourrez m'aider