Bonjour
Je souhaite mettre à jour des records à partir de php en faisant apparaitre le nom de la société et un nom (contact). j'ai d'abord une page (majmainframe.php) qui utilise une fonction d'édition du nom de la société dans la page majmainframe.php et qui me fait apparaître les champs à mettre à jour qui sont transmis par la méthode post à cli_mainframe.fr. Le problème rencontré est que la mise à jour écrase les lignes commençant par le même nom de société. Exemple
Si j'ai : FORD (SOCIETE) TOTO (NOM)
et : FORD (SOCIETE) TITI (NOM)
j'aurai après la mise à jour du premier enregistrement deux records identiques et l'information du deuxième enregistrement aura disparu.
FORD TOTO
FORD TOTO
Merci de l'aide que vous pouvez m'apporter
PAGE majmainframe.php =======>>>
form name="formmf" action="majmainframe.php" method="post">
PAGE cli_mainframe.php================>>>
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 <div align="center"> <table border="0" width="30%"> <tr> <td width="100%" colspan="12"><b><font color="#FF0000">Rechercher le client</font></b></td> </tr> <tr> <td width="20%" style="border-style: solid; border-color: #FF0000"> <?php lister2(mainframe,SOCIETE,lsociete,10); $requete="select SOCIETE,ADR1,ADR2,VILLE,CP,CIVILITE,NOM,PRENOM,FONCTION,TEL,FAX,EMAIL,DATE,COMMENTAIRES,CC from mainframe where SOCIETE='$lsociete' order by SOCIETE"; $resultat=mysql_query($requete) or die("requete echouee:<br>".mysql_error()); $result=mysql_fetch_row($resultat); ?> <input type="submit" value="ok" style="background-color: #0000FF; color: #FFFFFF; font-weight: bold; border: 3 solid #000080; padding-left: 7; padding-right: 7"> </td> <tr> </form> </table> </div> <form name="form_cli_mf" action="cli_mainframe.php" method="post"> <table border="0" width="100%" > <tr> <td width="100%" align="center" colspan="4"><b>SOCIETE</b></td> </tr> <tr> <td width="100%" colspan="4"><center><input name="societe" size="120" value="<?php echo "$societe$result[0]"; ?>" onFocus="this.select()"></center></td> </tr> <tr> <td width="40%" align="center"><b>ADR1</b></td> <td width="40%" align="center"><b>ADR2</b></td> <td width="15%" align="center"><b>VILLE</b></td> <td width="5%" align="center"><b>CP</b></td> </tr> <tr> <td width="40%"><center><input name="adr1" size="40" value="<?php echo "$adr1$result[1]"; ?>" onFocus="this.select()"></center></td> <td width="40%"><center><input name="adr2" size="40" value="<?php echo "$adr2$result[2]"; ?>" onFocus="this.select()"></center></td> <td width="15%"><center><input name="ville" size="40" value="<?php echo "$ville$result[3]"; ?>" onFocus="this.select()"></center></td> <td width="5%"><center><input name="cp" size="10" value="<?php echo "$cp$result[4]"; ?>" onFocus="this.select()"></center></td> </tr> <tr> <td width="2%" align="center"><b>CIVILITE</b></td> <td width="29%" align="center"><b>NOM</b></td> <td width="20%" align="center"><b>PRENOM</b></td> <td width="49%" align="center" colspan="2"><b>FONCTION</b></td> </tr> <tr> <td width="2%"><center><input name="civilite" size="5" value="<?php echo "$civilite$result[5]"; ?>" onFocus="this.select()"></center></td> <td width="29%"><center><input name="nom" size="40" value="<?php echo "$nom$result[6]"; ?>" onFocus="this.select()"></center></td> <td width="20%"><center><input name="prenom" size="40" value="<?php echo "$prenom$result[7]"; ?>" onFocus="this.select()"></center></td> <td width="49%"><center><input name="fonction" size="50" value="<?php echo "$fonction$result[8]"; ?>" onFocus="this.select()"></center></td> </tr> <tr> <td width="20%" align="center"><b>TEL</b></td> <td width="20%" align="center"><b>FAX</b></td> <td width="30%" align="center"><b>EMAIL</b></td> <td width="30%" align="center" colspan="2"><b>dérnière mise à jour effectuée le:</b></td> </tr> <tr> <td width="20%"><center><input name="tel" size="35" value="<?php echo "$tel$result[9]"; ?>" onFocus="this.select()"></center></td> <td width="20%"><center><input name="fax" size="35" value="<?php echo "$fax$result[10]"; ?>" onFocus="this.select()"></center></td> <td width="30%"><center><input name="email" size="40" value="<?php echo "$email$result[11]"; ?>" onFocus="this.select()"></center></td> <td width="30%"><center><input name="last_modif" size="20" style="border-style: solid; border-color: #FFFFFF" value="<?php echo "$der_date$result[12]"; ?>" onFocus="this.select()"></center></td> <?php echo "<input type=\"hidden\" name=\"ste\" value=\"$lsociete\">"; ?> </tr> <tr> <td width="20%" align="center"><b>COMMENTAIRES</b></td> <td width="20%" align="center"><b>CODE</b></td> </tr> <tr> <td width="20%"><center><input name="commentaires" size="35" value="<?php echo "$commentaires$result[13]"; ?>" onFocus="this.select()"></center></td> <td width="20%"><center><input name="cc" size="35" value="<?php echo "$cc$result[14]"; ?>" onFocus="this.select()"></center></td> </tr> </table>
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 if ($bouton=="CREER") { // insertion du nouvel enreg echo "$last_code_cli[0]"; $requete="INSERT INTO mainframe(SOCIETE,CIVILITE,NOM,PRENOM,FONCTION,TEL,EMAIL,FAX,ADR1,ADR2,CP,VILLE,DATE,LOGIN,COMMENTAIRES,CC) VALUES('$societe','$civilite','$nom','$prenom','$fonction','$tel','$email','$fax','$adr1','$adr2','$cp','$ville','$date','$login','$commentaires','$cc')"; $verif = mysql_query($requete,$id_connex); if ($verif) {echo "client $nom créé";} else {echo "Insertion impossible erreur N° ", mysql_errno(),mysql_error();} } else { // mise à jour de la table clients $requete="UPDATE mainframe SET SOCIETE='$societe',CIVILITE='$civilite', NOM='$nom', PRENOM='$prenom', FONCTION='$fonction', TEL='$tel', EMAIL='$email', FAX='$fax', ADR1='$adr1', ADR2='$adr2', CP='$cp', VILLE='$ville', DATE='$date', LOGIN='$login', COMMENTAIRES='$commentaires', CC='$cc' where SOCIETE='$ste'"; $verif = mysql_query($requete,$id_connex); if ($verif) {echo "client $societe mis à jour";} else {echo "Insertion impossible erreur N° ", mysql_errno(),mysql_error();} }
Partager