lecture en boucle for après mysql_fetch_array
Bonjour,
J'ai un soucis avec mon code PHP. Je charge les résultats d'une requête mysql dans une variable, et ensuite, j'arrive à lire la 1ère ligne seulement. Pour la deuxieme, j'ai l'erreur "Notice: Undefined offset: 1":
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
|
<p><center><b>Tournois prévus</b></center></p>
<br>
<center><TABLE BORDER="1" class="blanc">
<TR>
<TH width="200"> Date </TH>
<TH width="100"> Heure </TH>
<TH width="50"> Mise </TH>
</TR>
<?php
// Connexion à la BDD
mysql_connect("localhost", "root", "");
mysql_select_db("ltad");
// Récupération de l'auteur
$sql="SELECT count(id_tournoi) from tournoi where date_tournoi > NOW()";
$res = mysql_query($sql);
$resultat = mysql_fetch_array($res);
$nbtournoisprevus = $resultat[0];
$nbtournoisprevus = intval($nbtournoisprevus);
if ($nbtournoisprevus > 0)
{
// Récupération de la date du tournoi
$sql="SELECT date_tournoi from tournoi where date_tournoi >= NOW()";
$res = mysql_query($sql);
$datestournois = mysql_fetch_array($res);
// Récupération de l'heure du tournoi
$sql="SELECT heure_tournoi from tournoi where date_tournoi >= NOW()";
$res = mysql_query($sql);
$heurestournois = mysql_fetch_array($res);
// Récupération de la mise du tournoi
$sql="SELECT mise from tournoi where date_tournoi >= NOW()";
$res = mysql_query($sql);
$misestournois = mysql_fetch_array($res);
for($i = 0; $i < $nbtournoisprevus; $i++)
{
$heuretournoi = $heurestournois[$i];
$datetournoi = $datestournois[$i];
$misetournoi = $misestournois[$i];
?>
<TR>
<TD align = "left"> <?php echo "$datetournoi"?> </TD>
<TD align = "left"> <?php echo "$heuretournoi"?> </TD>
<TD align = "left"> <?php echo "$misetournoi"?> </TD>
</TR>
<?php
}
}
?>
</TABLE></center>
<!-- Déconnextion de la BDD -->
<?php mysql_close(); ?> |
quelqu'un saurait pourquoi?
Merci