ce code marche mais je pense qu'il y'a un truc plus juste que ça vu que je réécris la même chose dans les case1 et 2 ya juste le nom de la table qui change!!!
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=bitumepurs', 'root', '');
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
for($j=1;$j<=2;$j++)
{ 
switch ($j) 
{
case 1: 
 
$req = $bdd->prepare('INSERT INTO a40_50 ( 
stock_initial,
ent_importation,
ent_rav_naftal,
ent_rav_tiers,
ent_rav_clients,
ent_formulations,
ent_excedents,
sor_formulations,
sor_ventes,
sor_transferts,
sor_consom_interne,
sor_coul_pertes,
stock_final) VALUES(
:stock_initial,
:ent_importation,
:ent_rav_naftal,
:ent_rav_tiers,
:ent_rav_clients,
:ent_formulations,
:ent_excedents,
:sor_formulations,
:sor_ventes,
:sor_transferts,
:sor_consom_interne,
:sor_coul_pertes,
:stock_final)');
break;
case 2: 
$req = $bdd->prepare('INSERT INTO a0_1 ( 
stock_initial,
ent_importation,
ent_rav_naftal,
ent_rav_tiers,
ent_rav_clients,
ent_formulations,
ent_excedents,
sor_formulations,
sor_ventes,
sor_transferts,
sor_consom_interne,
sor_coul_pertes,
stock_final) VALUES(
:stock_initial,
:ent_importation,
:ent_rav_naftal,
:ent_rav_tiers,
:ent_rav_clients,
:ent_formulations,
:ent_excedents,
:sor_formulations,
:sor_ventes,
:sor_transferts,
:sor_consom_interne,
:sor_coul_pertes,
:stock_final)');
break;
}
 
 
 
 
 
 
 
 
$req->execute(array('stock_initial' => $_POST['l1c'.$j],
'ent_importation'    => $_POST['l2c'.$j],
'ent_rav_naftal'     => $_POST['l3c'.$j],
'ent_rav_tiers'      => $_POST['l4c'.$j],
'ent_rav_clients'    => $_POST['l5c'.$j],
'ent_formulations'   => $_POST['l6c'.$j],
'ent_excedents'      => $_POST['l7c'.$j],
'sor_formulations'   => $_POST['l8c'.$j],
'sor_ventes'         => $_POST['l9c'.$j],
'sor_transferts'     => $_POST['l10c'.$j],
'sor_consom_interne' => $_POST['l11c'.$j],
'sor_coul_pertes'    => $_POST['l12c'.$j],
'stock_final'        => $_POST['l13c'.$j]));
 
}
echo 'données on bien été ajouté !';
?>