Je n'arrive pas a faire affiché certaine informations liés à deux tables.
J'ai deux tables "FORMATION" & "CATEGORIE" - (Formation est lié catégorie)
Code : Tout sélectionner
-- Structure de la table `categorie`
--
CREATE TABLE `categorie` (
`id_categorie` int(11) NOT NULL auto_increment,
`txt_categorie` varchar(250) NOT NULL,
KEY `id_categorie` (`id_categorie`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;
-- --------------------------------------------------------
--
-- Structure de la table `formation`
--
CREATE TABLE `formation` (
`id_formation` int(11) NOT NULL auto_increment,
`id_categorie_formation` int(11) NOT NULL,
`nom_formation` varchar(250) NOT NULL,
`date_formation` date NOT NULL,
`ville_formation` varchar(250) NOT NULL,
`pays_formation` varchar(250) NOT NULL,
`publique_formation` longtext NOT NULL,
`objectif_formation` longtext NOT NULL,
`description_formation` longtext NOT NULL,
`program_formation` longtext NOT NULL,
KEY `id_formation` (`id_formation`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;
Ce que je souhaite faire
Faire afficher toutes les formations lié a chaque catégorie existante
Ce que j'ai déjà réalisé
Affiché toute les catégorie
$sql = "SELECT txt_categorie FROM categorie";
$sql_retour = mysql_query ($sql) or die (mysql_error());
while ($ligne = mysql_fetch_array($sql_retour))
{
// CREATION d'un tableau
echo '<table width="100%" border="0" cellspacing="1" cellpadding="0">';
echo '<tr>';
echo '<td colspan="5" id="recherche_date">';
// Cellule NOM FORMATION
echo '<span class="smallredtext">'.$ligne['txt_categorie'].'</span>' ;
echo '</td>';
echo '</tr>';
// CREATION d'une deuxieme Lignes
echo '<tr>';
//Titre des cellules
echo '<td width="20"> </td>';
echo '<td id="descriptif_Titre"><strong>Formation</strong></td>';
echo '<td id="descriptif_Titre"><strong>date</strong></td>';
echo '<td id="descriptif_Titre"><strong>Ville</strong></td>';
echo '<td id="descriptif_Titre"> </td>';
// Fin de la deuxième Ligne
echo '</tr>';
ensuite, c'est la ou est mon problème, je veux affiché toutes les formations associé à une catégorie.donc a la suite du code précédent j'ai mis :
// SELECTIONNER toute les donnée de la table formation et catégorie
$themes = $ligne['id_categorie'];
$sql2 = "SELECT *
FROM formation
WHERE id_categorie_formation = $themes
ORDER BY nom_formation ASC
";
$sql2_retour = mysql_query($sql) or die (mysql_error());
while ($affiche = mysql_fetch_array($sql2_retour))
{
// CREATION d'une troisieme Ligne
echo "<tr>";
// Cellule
echo '<td>';
echo ' ';
echo '</td>';
// Cellule NOM DE LA FORMATION
echo '<td id="descriptif">';
echo ucfirst(substr($affiche['nom_formation'],0,30));
echo '</td>';
// Cellule THEMES
echo '<td id="descriptif">';
echo ucfirst($ligne['date_formation']) ;
echo '</td>';
// Cellule THEMES
echo '<td id="descriptif">';
echo ucfirst($ligne['ville_formation']) ;
echo '</td>';
// Cellule + DE DETAIL
echo '<td id="descriptif">';
echo '<a href="programme_date.php?details='.$ligne['id_formation'].'" class="smallgraytext"><img src="images/detail.gif" alt="Détails de la formation" width="53" height="15" border="0" /></a>' ;
echo '</td>';
// FIN de la troisieme ligne
echo '</tr>';
}
// FIN du tableau
echo '</table><p></p><br />';
}
Le résultat à l'affichagele résultat n'est pas du tout ce que j'attendais, il ne m'affiche pas le nom, date et ville des formations, et surtout j'ai 5 lignes vide qui corresponde en faite au nombre de catégorie existante.
J'ai donc besoin de votre aide.
merci de votre participation