insert de la meme variable mais avec nom différents
Bonjour, le forum.
Comme a mon habitude, je vous sollicite pour un truc trés compliqué.
Je souhaite faire un tableau sportif PHP/SQL.
Le probleme vient du fait que je ne parvient pas a inserer dans la BDD les infos contenues dans les variables, le pb est d'identifier les variables dans mon insert :
Voici mon code :
fichier b.php
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
// je récupére dans l url la variable de la journée :
$j=@$_GET['j'];
// tableau comportant la journée, l equipe Domicile MD, le score domicile RD, l equipe exterieur ME et son resultat RE.
echo "<table border='0' cellpadding='0' cellspacing='0' width='300'>
<tr>
<td width='100%'>
<form method='POST' action='valide-b.php'>
<table border='0' cellpadding='0' cellspacing='0' width='300'>
<tr>
<td width='25%'>Journée :
<select onchange='document.location=(this.options[this.selectedIndex].value)' name='J'>
<option value='b.php?j=$j' selected>$j</option>
<option value='b.php?j=1'>1</option>
//etc...
</select>
</td>
<td width='14%'></td>
<td width='5%'></td>
<td width='12%'></td>
<td width='44%'></td>
</tr>
<tr>
<td width='25%'></td>
<td width='31%' colspan='3' align='center'><b><font size='4' face='Arial'>Score</font></b></td>
<td width='44%'></td>
</tr>";
// je liste les matchs de la journée selectionnée :
$res=mysql_query("SELECT * FROM L1R where J='$j'");
while($list = mysql_fetch_array($res, MYSQL_ASSOC))
{
$rd = 'RD' + $list['MD'];
$re = 'RE' + $list['ME'];
echo 'RD : $rd<br>RE : $re<br>';
echo '<tr>
<td width="25%">
<select size="1" name="MD'.$list['MD'].'">
<option value="'.$list['MD'].'" selected>'.$list['MD'].'</option>';
// liste des equipes qui recoivent
$reseq=mysql_query("SELECT * FROM L1 order by Pts ASC");
while($listeq = mysql_fetch_array($reseq, MYSQL_ASSOC))
{
$md = $list['MD'];
$me = $list['ME'];
echo '<option value="'.$listeq['EQ'].'">'.$listeq['EQ'].'</option>';
}
echo '</select>
</td>';
// resultat des match avec identification de chaque resultat dont une partie du nom est composé du nom de l'equipe pour l'update.
echo '<td width="14%"><input type="text" name="RD'.$list['MD'].'" size="2" value="'.$list['RD'].'"></td>
<td width="5%">-</td>
<td width="12%"><input type="text" name="RE'.$list['ME'].'" size="2" value="'.$list['RE'].'"></td>
<td width="25%">
<select size="1" name="ME'.$list['ME'].'">
<option value="'.$list['ME'].'" selected>'.$list['ME'].'</option>';
// liste des equipes reçues
$reseq=mysql_query("SELECT * FROM L1 order by Pts ASC");
while($listeq = mysql_fetch_array($reseq, MYSQL_ASSOC))
{
echo '<option value="'.$listeq['EQ'].'">'.$listeq['EQ'].'</option>';
}
echo '</select</td>
</tr>';
}
echo "</table><input name='valider' type='submit' value='VALIDER' style='font-size: 8 pt'>
</form>
</td>
</tr>
</table>
";
?> |
fichier valide-b.php qui reçoit les données
Soit rien ne foncitonne, soit il enregistre le dernier match
Code:
1 2 3
| // c'est ici que se pose mon PB, car il n'identifie que les variables du dernier match. C'est comme si je devais faire une boucle dans l'update.
$modif = mysql_query("UPDATE L1R SET RD='$rd', RE='$re' WHERE MD='$md' and ME='$me' and J='$j'");
?> |
Voici l'url du fichier. http://www.test-internet.com/b.php
Merci pour votre aide et bonne journée