j'essaie de retourner des résultats par le biais d'une requête sql mais l'affichage ne se fait pas comme je le souhaite...
Sont chargés dans ma base sql des événements pour l'année 2011 allant de JANVIER à DECEMBRE.
Ses informations sont affichées grace à un tableau en php.
Le problème c'est que toutes mes infos s'affichent dans le même tableau et non dans un tableau différent pour chaque mois.
Je souhaite que mes infos soient ordonnés par mois mais malgré les if tout reste dans le même tableau...
Voici la base sql:
--
-- Structure de la table `calendrier`
--
CREATE TABLE IF NOT EXISTS `calendrier` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`mois` varchar(20) COLLATE latin1_general_ci NOT NULL,
`date` date NOT NULL,
`epreuve` text COLLATE latin1_general_ci NOT NULL,
`formule` text COLLATE latin1_general_ci NOT NULL,
`lieux` text COLLATE latin1_general_ci NOT NULL,
`upload` varchar(150) COLLATE latin1_general_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=10 ;
--
-- Contenu de la table `calendrier`
--
INSERT INTO `calendrier` (`id`, `mois`, `date`, `epreuve`, `formule`, `lieux`, `upload`) VALUES
(1, 'MARS', '2011-03-30', 'Pro''AM', '1+1', 'Bethemont', ''),
(2, 'JUILLET', '2011-07-24', 'Ceci est un test', 'deux joueurs', 'Villennes sur seine', 'docs_calendrier/'),
(3, 'AVRIL', '2011-04-19', 'test test test test', 'youplaboum', 'Paris 17', ''),
(4, 'DECEMBRE', '2011-12-29', 'Test', 'deux + deux', 'Chambourcy', 'upload/'),
(5, 'DECEMBRE', '2011-12-27', 'Test', '3 + 3', 'Chambourcy', 'upload/'),
(6, 'DECEMBRE', '2011-12-20', 'Test', '4+4', 'Chambourcy', 'upload/'),
(7, 'DECEMBRE', '2011-12-12', 'Test', '5+5', 'Chambourcy', 'upload/'),
(8, 'DECEMBRE', '2011-12-05', 'Test', '6+6', 'Chambourcy', 'upload/'),
(9, 'DECEMBRE', '2011-12-10', 'Test', '7+7', 'Chambourcy', 'upload/');
Et la mon PHP qui permet d'afficher les résultats suivant chaque mois (pour le moment j'ai fait le test sur le mois de mars et decembre...
<?php
//------------------------------ entete de la page -----------------------------------------
include_once("haut.php");
//------------------------------------------------------------------------------------------
//------------------------------CONNEXION BASE CALENDRIER--------------------------//
$conn = db_connect();
$sql = "SELECT * FROM calendrier ORDER by date ASC";
$result = mysql_query($sql, $conn);
$resultat = mysql_query($sql, $conn);
$mois = mysql_fetch_array($result);
?>
<fieldset class="fieldset">
<legend class="legend"><span class="titr2">Calendrier 2011</span></legend>
<?php
if ($mois['mois'] == "MARS") {
while ($calendrier = mysql_fetch_array($result)) {
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="16%" align="center" valign="middle" bgcolor="#5bc210" style="padding-bottom:10px;"> <strong><center><?php echo $calendrier['mois']?></center></strong></td>
<td width="32%"> </td>
<td width="22%"> </td>
<td width="15%"> </td>
<td width="15%"> </td>
</tr>
<tr bgcolor="#5bc210">
<td style="padding-bottom:10px; padding-left:5px;">Date</td>
<td style="padding-bottom:10px; padding-left:5px;">Epreuve</td>
<td style="padding-bottom:10px; padding-left:5px;">Formule</td>
<td style="padding-bottom:10px; padding-left:5px;">Lieux</td>
<td style="padding-bottom:10px; padding-left:5px;">Infos</td>
</tr>
<tr bgcolor="#252525">
<td style="padding-bottom:10px; padding-left:5px; color:#9c9d9f;"><?php echo $calendrier['date'] ?></td>
<td class="bordure" style="padding-bottom:10px; padding-left:5px; color:#9c9d9f;"><?php echo $calendrier['epreuve'] ?></td>
<td style="padding-bottom:10px; padding-left:5px; color:#9c9d9f;"><?php echo $calendrier['formule'] ?></td>
<td class="bordure" style="padding-bottom:10px; padding-left:5px; color:#9c9d9f;"><?php echo $calendrier['lieux'] ?></td>
<td style="padding-bottom:10px; padding-left:5px; color:#9c9d9f;"><center><a href="<?php echo $calendrier['upload'] ?>"><img src="images/pdf.jpg" alt="Télécharger le PDF" /></a>
</center></td>
</tr>
</table>
<?php } } ?>
<br />
<?php
if ($mois['mois'] == "DECEMBRE") {
while ($calendrier = mysql_fetch_array($result)) {
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="16%" align="center" valign="middle" bgcolor="#5bc210" style="padding-bottom:10px;"> <strong><center><?php echo $calendrier['mois']?></center></strong></td>
<td width="32%"> </td>
<td width="22%"> </td>
<td width="15%"> </td>
<td width="15%"> </td>
</tr>
<tr bgcolor="#5bc210">
<td style="padding-bottom:10px; padding-left:5px;">Date</td>
<td style="padding-bottom:10px; padding-left:5px;">Epreuve</td>
<td style="padding-bottom:10px; padding-left:5px;">Formule</td>
<td style="padding-bottom:10px; padding-left:5px;">Lieux</td>
<td style="padding-bottom:10px; padding-left:5px;">Infos</td>
</tr>
<tr bgcolor="#252525">
<td style="padding-bottom:10px; padding-left:5px; color:#9c9d9f;"><?php echo $calendrier['date'] ?></td>
<td class="bordure" style="padding-bottom:10px; padding-left:5px; color:#9c9d9f;"><?php echo $calendrier['epreuve'] ?></td>
<td style="padding-bottom:10px; padding-left:5px; color:#9c9d9f;"><?php echo $calendrier['formule'] ?></td>
<td class="bordure" style="padding-bottom:10px; padding-left:5px; color:#9c9d9f;"><?php echo $calendrier['lieux'] ?></td>
<td style="padding-bottom:10px; padding-left:5px; color:#9c9d9f;"><center><a href="<?php echo $calendrier['upload'] ?>"><img src="images/pdf.jpg" alt="Télécharger le PDF" /></a>
</center></td>
</tr>
</table>
<?php } } ?>
<br />
</fieldset>
<?php
//------------------------------------------- bas de page -----------------------------------
include_once("bas.php");
//-------------------------------------------------------------------------------------------
?>
Merci beaucoup.