j’arrive a envoyer des informations a partir d'un fichier .csv
mais mon script n’envoie que le dernier record sur 5 pourquoi ?
merci a l'avance !
page un : test.php
<?php
$con = mysql_connect("...","...","...");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("club", $con);
//ouvre le fichier csv
$f = fopen ("tournois.csv", "r");
$ln= 0;
while ($line= fgets ($f)) {
++$ln;
// printf ("%2d: ", $ln);
if ($line===FALSE) print ("FALSE\n");
//print $line;
//explode separe la variable entre les ;
$part=explode(";",$line);
//echo $part[0];
//$part=mysql_fetch_assoc($part1);
//$part=mysql_query($part1);
echo ('<form action="test2.php" name="Formu" method="POST">');
echo ('<table border="1">');
echo ('<tr>');
echo ('<td>Date : <input name="dates" readonly="readonly" type="text" value="' . $part[0] . '" style="width:6em" /></td>');
echo ('<td>Section : <input name="section" readonly="readonly" type="text" value=' . $part[1] . ' style="width:4em" /></td>');
echo ('<td>Nombre jrs : <input name="nbrjoueurs" readonly="readonly" type="text" value=' . $part[2] . ' style="width:6em" /></td>');
echo ('<td>Participants : <input name="participants" readonly="readonly" type="text" value=' . $part[3] . ' style="width:7em" /></td>');
echo ('<td>Cotes Avant : <input name="cotesAv" readonly="readonly" type="text" value=' . $part[4] . ' style="width:15em" /></td>');
echo ('<td>Cotes Perfo. : <input name="cotesPerf" readonly="readonly" type="text" value=' . $part[5] . ' style="width:15em" /></td>');
echo ('<td>Cotes Après : <input name="cotesAp" readonly="readonly" type="text" value=' . $part[6] . ' style="width:15em" /></td>');
echo ('<td>perms : <input name="perms" readonly="readonly" type="text" value=' . $part[7] . ' style="width:15em" /></td>');
echo ('<td>Resultats : <input name="resultats" readonly="readonly" type="text" value=' . $part[8] . ' style="width:15em" /></td>');
echo ('</tr>');
echo ('</table>');
}
echo ('<input type="submit" value="Ajouter">');
echo ('</form>');
fclose ($f);
?>
et la page test2.php
<?php
$con = mysql_connect("...","...","...");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("club", $con);
$sql = mysql_query("INSERT INTO tournois (dates, section, nbrjoueurs, participants, cotesAv, cotesPerf, cotesAp, perms,resultats) VALUES ('".$_POST[dates]."','".$_POST[section]."','".$_POST[nbrjoueurs]."','".$_POST[participants]."','".$_POST[cotesAv]."','".$_POST[cotesPerf]."','".$_POST[cotesAp]."','".$_POST[perms]."','".$_POST[resultats]."')");
echo ('<div align="center">');
echo ('<table width="300" border="1" align="center">');
echo ('<tr>');
echo ('<td width="263" class=tdx><div align="center">Le nouveau tournoi est ajouter.</div></td>');
echo ('</tr>');
echo ('<table border="1">');
echo ('<tr>');
echo ('<td>Date</td>');
echo ('<td width="155" name="dates">' . $_POST[dates] .'</td><p>');
echo ('</tr>');
echo ('<tr>');
echo ('<td>Section</td>');
echo ('<td width="155" name="section">' . $_POST[section] . '</td>');
echo ('</tr>');
echo ('<tr>');
echo ('<td>Nom. Joueurs</td>');
echo ('<td width="155" name="nbrjoueurs">' . $_POST[nbrjoueurs] . '</td>');
echo ('</tr>');
echo ('<tr>');
echo ('<td>Participants</td>');
echo ('<td width="155" name="participants">' . $_POST[participants] . '</td>');
echo ('</tr>');
echo ('<tr>');
echo ('<td>Cote Avant</td>');
echo ('<td width="155" name="cotesAv">' . $_POST[cotesAv] . '</td>');
echo ('</tr>');
echo ('<tr>');
echo ('<td>Cote Perfo.</td>');
echo ('<td width="155" name="cotesPerf">' . $_POST[cotesPerf] . '</td>');
echo ('</tr>');
echo ('<tr>');
echo ('<td>Cote Apres</td>');
echo ('<td width="155" name="cotesAp">' . $_POST[cotesAp] . '</td><br>');
echo ('</tr>');
echo ('<tr>');
echo ('<td>Performance</td>');
echo ('<td width="155" name="perms">' . $_POST[perms] . '</td>');
echo ('</tr>');
echo ('<tr>');
echo ('<td>Resultats</td>');
echo ('<td width="155" name="resultats">' . $_POST[resultats] . '</td>');
echo ('</tr>');
echo ('</table>');
echo ('</table>');
echo ('</div>');
mysql_close()
?>
donc en plus simple mon script affiche seulement le dernier record sur 5 et fait de même dans ce qu'il envois dans la BD !?
merci je crois pas que ce ne sois un gros problème une connerie comme d'habitude !!!
