Mon projet avance avec votre aide, je progresse, j'apprends mais reste toujours débutant.
Voilà, j'ai une page avec le formulaire suivant que vous m'avez aidé à construire :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?php
require ('conf.php');
//Fichier de réception du formulaire listecole.php
$postecole = $_POST['ecole'];
echo ("<b>Ecole</> : $postecole<br/><br>");
 
$query = mysql_query("SELECT  id_nom, Nom, Prénom, animob, date_1, date_2 FROM jos_ecole_etat, jos_ecole_animob WHERE jos_ecole_etat.ECOLE ='$postecole' AND jos_ecole_animob.ECOLE = '$postecole'") OR die("impossible");
$rqani = mysql_query("SELECT anim, id_anim FROM jos_ecole_anim_ci ORDER BY id_anim") OR die("impossible");
$rqanidv = mysql_query("SELECT anim_dv, id_animdv FROM jos_ecole_anim_dv ORDER BY id_animdv") OR die("impossible");
echo "<form action='test3.php' name='id_anim' method='POST'>";
echo "<table border='1' cellpadding='1' cellspacing='1' align='left'>
				<td><b>Nom</b></td>
				<td><b>Prénom</b></td>
                <td><b><center>Animations obligatoires</center></b></td>
                <td><b>Animations circo</b></td>
                <td><b>Animations autres</b></td>
                </tr>";
 
while ($row=mysql_fetch_array($query))
{
 
  $date_1 = datefr($date=$row[date_1]);
  $date1 = $datefr;
  $date_2 = datefr($date=$row[date_2]);
  $date2 = $datefr;
 
echo "<tr>";
echo "<td>";
echo "$row[Nom]";
echo "</td>";
echo "<td>$row[Prénom]</td>";
echo "<td>";
echo "<center>$row[animob]<br/>$date1 et $date2</center>";
echo "</td>";
echo "<td>";
echo "<center><select name=\"id_anim[$row[id_nom]\"><option value=\"\">< Choisir ></option></center>";
 
if( ! isset($tab_maliste)) {
 
  while (list($anim, $id_anim) = mysql_fetch_row($rqani)) {
    $tab_maliste[$id_anim ] = $anim;
    echo "<option value=\"$id_anim\">$anim</option>\r\n";
  }
} else {
  foreach($tab_maliste as $cle => $val) {
    echo "<option value=\"$cle\">$val</option>\r\n";
  }
}
echo "</select></td>";
//seconde liste
echo "<td>";
echo "<center><select name=\"id_animdv[$row[id_nom]\"><option value=\"\">< Choisir ></option></center>";
 
if( ! isset($tab_malistedv)) {
 
  while (list($animdv, $id_animdv) = mysql_fetch_row($rqanidv)) {
    $tab_malistedv[$id_animdv ] = $animdv;
    echo "<option value=\"$id_animdv\">$animdv</option>\r\n";
  }
} else {
  foreach($tab_malistedv as $cledv => $valdv) {
    echo "<option value=\"$cledv\">$valdv</option>\r\n";
  }
}
echo "</select></td>";
 
echo "<tr>
";
}
echo "</table>";
echo "<input type='submit' value='envoyer'/>";
echo "</form>";
 
  function datefr($date=0)
  {
  $annee = substr($date, 0, 4);
  $mois = substr($date, 5, 2);
  $jour = substr($date, 8, 2);
  global $datefr;
  $datefr = $jour . '-' . $mois . '-' . $annee;
  }
?>
La page m'affiche un tableau complet. J'envoie le formulaire dans la page suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?php
require ('conf.php');
 
echo "<table border='1' cellpadding='1' cellspacing='1' align='left'>
                <td><b>ECOLE</b></td>
                <td><b>Nom</b></td>
		  		<td><b>Prénom</b></td>
                <td><b>Animations obligatoires</b></td>
                <td><b>Animations circo</b></td>
                <td><b>Animations autres</b></td>
                </tr>";
if (isset($_POST['id_anim']));
    foreach($_POST as $idNom => $idAnim)
    {
 
                $NOM = substr ($idNom, 8);
                $rqani = mysql_query("SELECT anim, Nom, Prénom, ECOLE, id_animdv, anim_dv FROM jos_ecole_anim_ci, jos_ecole_etat, jos_ecole_anim_dv WHERE id_anim='$idAnim' AND id_nom='$NOM'") OR die("impossible");
 
                    while ($recup=mysql_fetch_array($rqani))
                    {
 
            echo "<tr><td>$recup[ECOLE]</td><td>$recup[Nom]</td><td>$recup[Prénom]</td><td>$recup[animob]</td><td>$recup[anim]</td><td>$recup[anim_dv]</td><tr>";
 
            $inscrit = "INSERT INTO jos_ecole_animation (ecole, nom, prenom, anim_ci)
            VALUES ('$recup[ECOLE]', '$recup[Nom]','$recup[Prénom]','$recup[anim]')";
            $envoi = mysql_query($inscrit);
                    }
    }
?>
Et là, je galère car je n'arrive pas à récupérer tout ce que je veux. Mon tableau fonctionne pour Ecole, Nom, Prénom
Pour 'Animations obligatoires', rien mais j'ai enlevé la requête qui ne fonctionnait pas !
Pour 'Animations circo', il choisit bien les choix que j'avais fait mais il répète plusieurs fois la même info à cause de 'Animations autres' qui liste toutes les 'Animations autres'...
J'ai pensé à une boucle inclue dans une autre mais je ne dois pas être très doué ou ce n'est pas la solution.
J'ai lu, cherché sur la toile mais je ne comprends pas comment faire... Merci