1 pièce(s) jointe(s)
Problème de boucle en récupérant les données dans un tableau
Bonjour,
J'ai une table (jos_ecole_animation) qui reçoit des données dans 3 colonnes en particulier (anim_ob, anim_ci, anim_dv).
Les informations qui arrivent dans ces colonnes proviennent de 3 tables (jos_ecole_animob, jos_ecole_anim_ci, jos_ecole_anim_dv )
Je veux afficher les résultats de jos_ecole_animation dans un tableau en associant les dates de chaque "anim" et ces dates sont stockées dans les 3 autres tables.
J'ai écrit le script suivant, tout semble bien se passer, sauf que si une cellule est vide, la date de la cellule précédente s'inscrit ! (cf image jointe).
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| <?php
echo "<b>Inscriptions de l'école : $_POST[ecole]</b><br/><br/>";
if ( isset ($_POST['ecole']))
{
$resec = mysql_query("SELECT ecole, nom, prenom, anim_ob, anim_ci, anim_dv, projet FROM jos_ecole_animation WHERE ecole='$_POST[ecole]'") OR die("impossible");
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' align='center'>
<tr>
<td><b>Nom</b></td>
<td><b>Prénom</b></td>
<td><b><center>Animation 1</center></b></td>
<td><b><center>Animation 2</center></b></td>
<td><b><center>Animation 3</center></td>
</tr>";
while ($row=mysql_fetch_array($resec))
{
$projet=$row[projet];
$rowanimob=$row[anim_ob];
$rowanimob = addslashes($rowanimob);
$rowanimci=$row[anim_ci];
$rowanimci = addslashes($rowanimci);
$rowanimdv=$row[anim_dv];
$rowanimdv = addslashes($rowanimdv);
$sql = mysql_query("SELECT date_format(date_1ob,'%d-%m-%y')AS date1ob, date_format(date_2ob,'%d-%m-%y')AS date2ob FROM jos_ecole_animob WHERE animob='$rowanimob'") OR DIE ("IMPOSSIBLE SQL");
If ( isset($rowanimob))
{
while ($rows=mysql_fetch_array($sql))
{$date1ob = $rows[date1ob];
$date2ob = $rows[date2ob];}
}
$sql1 = mysql_query("SELECT date_format(date_1,'%d-%m-%y')AS date1ci, date_format(date_2,'%d-%m-%y')AS date2ci FROM jos_ecole_anim_ci WHERE anim = '$rowanimci'") OR DIE ("IMPOSSIBLE1");
If ( isset($rowanimci))
{
while ($rows1=mysql_fetch_array($sql1))
{$date1ci = $rows1[date1ci];
$date2ci = $rows1[datecib];}
}
$sql2 = mysql_query("SELECT date_format(date_1,'%d-%m-%y')AS date1dv, date_format(date_2,'%d-%m-%y')AS date2dv FROM jos_ecole_anim_dv WHERE anim_dv = '$rowanimdv'") OR DIE ("IMPOSSIBLE2");
If ( isset($rowanimdv))
{
while ($rows2=mysql_fetch_array($sql2))
{$date1dv = $rows2[date1dv];
$date2dv = $rows2[date2dv];}
}
echo"<tr><td>$row[nom]</td><td>$row[prenom]</td><td><center>$rowanimob<br/>$date1ob et $date2ob</center></td><td><center>$rowanimci<br/>$date1ci et $date2ci</center></td><td><center>$rowanimdv<br/>$date1dv et $date2dv</center></td><tr>";
}
echo "</table>";
}
echo "<br/>";
echo "Projet d'école : $projet";
echo "<br/>";
?> |
Je tourne en rond depuis un moment et je ne trouve pas mon erreur. Merci de m'aider à y voir plus clair.