je suis en PFE dev site dynamique
J'ai 3 tables Client, Formation et inscription
les PK de client et formation sont FK dans inscription
voici mes tables:
Code SQL : 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 create table Client ( n_clt int not null, nom_clt text, prenom_clt text, profession_clt text, etablissement_clt text, niveau_clt text, adr_mail_clt text, n_tel_clt bigint, primary key (n_clt) ) type = InnoDB; create table Formation ( n_formation int not null, nom_formation text, nom_module text, date_formation date, formule_formation text, primary key (n_formation) ) type = InnoDB; create table Inscription ( n_clt int not null, n_formation int not null, n_inscription int, date_inscription date, etat_inscription text, mode_reglement text, primary key (n_clt, n_formation) ) type = InnoDB;
et pour les clés étrangères :
Code SQL : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 alter table Inscription add constraint FK_Adherer_formation1 foreign key (n_clt) references Client (n_clt) on delete restrict on update restrict; alter table Inscription add constraint FK_Adherer_formation2 foreign key (n_formation) references Formation (n_formation) on delete restrict on update restrict;
lors de l'enregistrement "php"
tout va bien mais seules les clés étrangères restent à 0
et lors d'un 2éme enregistrement====>"Erreur"
voici la source 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 $requet1= ( "INSERT INTO client (nom_clt, prenom_clt, profession_clt, etablissement_clt, niveau_clt, adr_mail_clt, n_tel_clt) VALUES ('$nom', '$prenom', '$profession', '$etablissement', '$niveau', '$email', '$tel')"); $requet2= ("INSERT INTO formation (nom_formation, nom_module, date_formation, formule_formation) VALUES ('$matiere', '$module', '$date', '$formule')"); $nclient="select max(n_clt) from client "; $nformation="select max(n_formation) from formation"; $requet3= ("INSERT INTO inscription (n_clt, n_formation, date_inscription, etat_inscription, mode_reglement) VALUES ('$nclient', '$nformation', CURRENT_TIMESTAMP, '$val', '$val')"); if(($enreg1=mysql_query($requet1 )) && ($enreg2=mysql_query($requet2)) && ($enreg3=mysql_query($requet3))) { echo"Mersi de votre confiance"; }else{ echo"Erreure de base de donnée."; }
j'ai essayé plein de trucs mais rien à faire
SVP aidez moi!!!!!!!!!!!!!!!!
Partager