Bonjour,
voila le script que j'ai réalisé.Mais mon proplème est que j'arrive pas à insérer dans mes 2tables.
Je ne vois pas d'ou vient le problème.aidez moi svp!!!!!!!

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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php 
$titre="Nouvelle Commande";
include_once("entete.php");
include_once("menu.php");
include_once("configuration.php");
?>
 
 
 <div id="corps">
 
<?php
//sauvegarde de la date au format Mysql
$date=date('Y-m-d');
echo $date.'<br/>';
 
$id_client= isset($_POST['id_client']) ? $_POST['id_client'] : '';
$nombre_article= isset($_POST['nombre_article']) ? $_POST['nombre_article'] : '';
 
 
for($p=1;$p<=$nombre_article;$p++)
{
$quantite_article = "quantite_article_" . $p;
$$quantite_article = isset($_POST["$quantite_article"]) ? $_POST["$quantite_article"] : ''; 
$$quantite_article= mysql_real_escape_string(htmlspecialchars($$quantite_article));
 
$id_article = "id_article_" . $p;
$$id_article = isset($_POST["$id_article"]) ? $_POST["$id_article"] : ''; 
$$id_article= mysql_real_escape_string(htmlspecialchars($$id_article));
 
}
$selection= isset($_POST['selection']) ? $_POST['selection'] : '';
 
$valide= isset($_POST['valide']) ? $_POST['valide'] : '';
 
if (!$selection and !$valide)
 
{
?>
 
 
<h2>Nouvelle Commande</h2>
 
<form action="creation_commande.php" method="POST">
<table>	
	<tr><td>
	Selection du Client:
	</td><td>
	<select name="id_client">
 
 
<?php
 
	// Sélectionner les champs "nom_emplacement"
	//selection emplacement plein 
	$req5="select id_client,nom_client,prenom_client,num_client from client";
	$reponse5 = mysql_query($req5);
 
 
	while ( $donnees5 = mysql_fetch_array($reponse5) )
	{
 
	$j=$donnees5['nom_client'];
	$id=$donnees5['id_client'];
	echo '<option value="'.$id.'">'.$j.'</option>';
 
	}	
	?>
 
	</select>
	</td></tr>
	<tr><td>
	Nombre d'article diffèrents :
	</td><td>
	<select name="nombre_article">
 
		<?php
 
	// Nombre article different disponible
 
	$req6="SELECT COUNT(*) AS nombre_article FROM article";
	$reponse6 = mysql_query($req6);
	$donnees6 = mysql_fetch_array($reponse6);
 
 
	$nombre_article= $donnees6['nombre_article'];
 
 
	for ($i=1;$i<=$nombre_article;$i++)
	{
	echo '<option >'.$i.'</option>';
	}	
 
 
	?>	
 
	</select>
	</td></tr>
 
		<label for="numero_commande">Numéro commande : </label>
	    <input name="numero_commande" /> <br />
 
		<label for="date_commande">Date commande : </label>
	    <input onclick="ds_sh(this);" name="date_commande" readonly="readonly" style="cursor: text" /><br />
 
		<label for="montant_global">Montant global : </label>
	    <input name="montant_global" /> <br />
 
	<tr><td>
	</td><td>
	<input type="submit"  name="selection" value="OK"/>
	</td></tr>
</table>
 
</form>
 
 
 
	   <?php
 
}
//on recupere les valeurs
if ($selection)
 
{
$selection= mysql_real_escape_string(htmlspecialchars($selection));
$id_client= mysql_real_escape_string(htmlspecialchars($id_client));
$nombre_article= mysql_real_escape_string(htmlspecialchars($nombre_article));
 
echo 'Client n° : '.$id_client.'<br/>';
 
echo 'Code article different :'.$nombre_article.'<br/>';
 
 
echo '<form action="creation_commande.php" method="POST">';
 
for($l=1;$l<=$nombre_article;$l++)
{
echo 'Article n° :'.$l.' ';
echo '<select name="id_article_'.$l.'">';
 
	// Sélectionner les champs "Type_article (ou le nom du materiel)"
 
	$reponse = mysql_query("select nom_materiel from materiel");
	while ( $donnees = mysql_fetch_array($reponse) )
	{
	$j=$donnees['nom_materiel'];
	$w=$donnees['id_materiel'];
	echo '<option value="'.$w.'">'.$j.'</option>';
	}
 
 
echo '</select>';
 
echo ' Quantité : ';
echo '<input type="text" name="quantite_article_'.$l.'" /><br/>';
}
echo '<p><input type="submit" value="OK" name="valide" /></p>';
 
echo '<input type="hidden" name="id_client" value="'.$id_client.'"  />';
 
echo '<input type="hidden" name="nombre_article" value="'.$nombre_article.'"  />';
 
echo '</form>';
 
 
}
 
//on insert dans la base
if ($valide)
{
$valide= mysql_real_escape_string(htmlspecialchars($valide));
 
// insertion de la nouvelle commande
$req="INSERT INTO `dicteenum`.`commande` (`id_commande` ,`client_id_client` ,`numero_commande`,`date_commande`,`montant_global`)
VALUES ('','".$_POST['id_client']."','".$_POST['numero_commande']."','".$_POST['date_commande']."','".$_POST['montant_global']."')";
$reponse = mysql_query($req);
 
	// aide
	if(mysql_error())
	{
	echo 'Debug : '.mysql_error().'<br />';
	}else{
	echo 'pas d\'erreur'.'<br />';
	}
 
$req2="select max(id_commande) as id_commande from commande";
$reponse2=mysql_query($req2);
$donnees2=mysql_fetch_array($reponse2);
 
$id_commande=$donnees2['id_commande'];
 
for ($p=1;$p<=$nombre_article;$p++)
 
{
$id_article = "id_article_" . $p;
$quantite_article = "quantite_article_" . $p;
 
 
$req3="insert into contient values ('$id_commande','${$nom_materiel}','${$quantite_article}')";
$reponse3=mysql_query($req3);
}
 
echo '<br/>Nouvelle commande créée';
 
}
 
?>
 
</div>
 
<?php 
include_once("pied_de_page.php");
?>