J'ai évidement un problème je n'arrive pas à insérer tous les enregistrements sélectionnés.
J'ai une requête UNION qui liste le membre, son conjoint et ses enfants ces informations se trouvent dans 2 tables la table membre et la table enfant.
Ensuite j'affiche les informations dans un formulaire, le code génère autant de formulaire que d'enregistrement le bouton SUMIT est sortie de la boucle.
Si je clique dessus un seul enregistrement est insérer, après de nombreuses recherche je pense que les enregistrements s'écrassent et seulement le dernier est inséré dans la base.
J'ai essayé sans succés
<td><input type="text" id="id_perso" [u]name="id_perso[<?php echo $affiche["id_perso"];?>]" [/u]size="4" maxlength="6" value="'.$affiche["id_perso"].'" ></td>
Voici le code de ma page
?>
<?php
$req1 = $bd->query('SELECT id, id_ligne_voyage, destination, DATE_FORMAT(date_debut, "%d/%m/%Y") as date_debut, DATE_FORMAT(date_fin, "%d/%m/%Y") as date_fin,
nbre_place, montant_g
FROM param_voyage WHERE id_ligne_voyage ="' . $_SESSION['id_voy']. '" ');
$donnees1 = $req1->fetch();
?>
<?php
echo "<p><B>Voyage sélectionné " .$donnees1['destination'].
" du " .$donnees1['date_debut']. " au " .$donnees1['date_fin']." Nbre de places " .$donnees1['nbre_place']. " Montant global " .$donnees1['montant_g']." €</B></p>";
?>
<form method="post" action="select_voyageur.php">
<p>
<label for="profil">Veuillez...</label>
<select id="matricule" name="matricule">
<option selected="selected"></option>
<?php
$req = $bd->query('SELECT matricule, id, nom, prenom FROM membre ORDER BY nom ASC');
while ($liste = $req->fetch())
{
echo '<option value="'.$liste["matricule"].'""'.stripslashes(strtoupper($liste["nom"])).'""'.stripslashes($liste["prenom"]).'">'. stripslashes(strtoupper($liste["nom"])).' '. stripslashes($liste["prenom"]).'</option>';
}
session_start();
$_SESSION['id_mat']=$_POST["matricule"];
?>
</select>
<input type="submit" value="Rechercher" />
</p>
</form>
<?php
if (isset($_POST['matricule']))
{
echo "<p>Profil sélectionné " . stripslashes($_SESSION['id_mat'])."</p>";
?>
<?php
$voyageur = $bd->query('SELECT
membre.id as "id_perso",
"Mem" as "type",
membre.matricule as "matricule",
membre.civilite as "civilite",
membre.nom as "nom",
membre.nom_j_fille as "nom_j",
membre.prenom as "prenom",
DATE_FORMAT(membre.date_n, "%d/%m/%Y") as "date_n",
"" as "select"
FROM membre
where membre.matricule="'.$_SESSION['id_mat'].'"
UNION
SELECT
membre.id as "id_perso",
"Conj" as "Type",
membre.matricule as "matricule",
membre.civilite_conj as "civilite",
membre.nom_conj as "nom",
membre.jeune_fille_conj as "nom_j",
membre.prenom_conj as "prenom",
DATE_FORMAT(membre.naissance_conj, "%d/%m/%Y") as "date_n",
"" as "select"
FROM membre where membre.matricule="'.$_SESSION['id_mat'].'"
UNION
SELECT
enfant.id as "id_perso",
"Enf" as "type",
enfant.matricule as "matricule",
enfant.civilite_enfant as "civilite",
enfant.nom_enfant as "nom",
"" as "nom_j",
enfant.prenom_enfant as "prenom",
DATE_FORMAT(enfant.naissance_enfant, "%d/%m/%Y") as "date_n",
"" as "select"
FROM enfant where enfant.matricule="'.$_SESSION['id_mat'].'"
');
while ($affiche = $voyageur->fetch()) {
echo '
<form name="insertion" action="ex_insert_voyageur.php" onsubmit="return verifForm(this)" method="POST">
<table width="91%" >
<tbody>
<td><input type="text" id="id_perso" name="id_perso" size="4" maxlength="6" value="'.$affiche["id_perso"].'" ></td>
<td><input type="text" id="id_ligne_voyage" name="id_ligne_voyage" size="20" maxlength="15" value="'.$donnees1["id_ligne_voyage"].'" ></td>
<td><input type="text" id="destination" name="destination" size="20" maxlength="15" value="'.$donnees1["destination"].'" ></td>
<td><input type="text" id="type" name="type" size="4" maxlength="3" value="'.$affiche["type"] .'" ></td>
<td><input type="text" id="matricule" name="matricule" size="6" maxlength="6" value="'.$affiche["matricule"].'" ></td>
<td>
<select style="width:110px;" id="civilite" name="civilite" >
<option selected="selected">'.$affiche["civilite"].'</option>
<option value="Monsieur" >Monsieur</option >
<option value="Madame">Madame</option >
</select></td>
<td><input type="text" id="nom" name="nom" size="20" maxlength="255" value="'.$affiche["nom"].'" ></td>
<td><input type="text" id="nom_j" name="nom_j" size="20" maxlength="255" value="'.$affiche["nom_j"].'" ></td>
<td><input type="text" id="prenom" name="prenom" size="25" maxlength="255" value="'.$affiche["prenom"] .'" ></td>
<td><input type="date" id="date_n" name="date_n" size="8" maxlength="15" value="'.$affiche["date_n"].'" ></td>
</tr>
</tbody>
</table>
';
}
echo '<td size="5"><input type="submit" value="OK"></td>';
echo '</form>';
}
else {
echo "<H3>En attente de sélection d'un profil</H3>";
}
?>
Merci de vos réponses.