Bonjour, suis à la demande de ma belle-fille qui tient un petit commerce de restauration. elle m'a demandé de créer un style de menu qui tourne via intranet.
J'ai quelques soucis avec mon premier script d'insertion, il me dit que ma commande est vide.
Ajouter des onglets suivant les catégories de produits, café, sandwichent, etc. valider dans une seule page ?
Merci de votre aide.
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 <?PHP header('Content-type: text/html; charset=UTF-8'); $choix = filter_input(INPUT_POST, 'choix'); $table = filter_input(INPUT_POST, 'table'); $message = ''; if(!empty($choix)){ require("function.php"); $connection = connexion_db (); foreach($choix as $liste) { $insert_prep=array(':article'=> $liste, ':table'=> $table, ':date_enregistrement'=> date("Y-m-j H:i:s")); $value_choix = implode(', ',array_keys($insert_prep)); $inser_exec=$connection->prepare( 'INSERT INTO commande ('.str_replace(':','',$value_choix).') VALUES('.$value_choix.')'); $inser_exec->execute($insert_prep); } if ($inser_exec === true) { header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/commande_passer.php"); } }else { /* Au moins un choix dans la commande*/ $message = 'Passer votre commande, car elle est vide.'; } ?> <!doctype html> <html lang="fr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style_co.css"> <title>commande</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> <script type="text/javascript"> // Une fois le chargment de la page terminé ... $(document).ready(function(){ // Lorsqu'un lien a.tab est cliqué $("a.tab").click(function () { // Mettre toutes les onglets non actif $(".active").removeClass("active"); // Mettre l'onglet cliqué actif $(this).addClass("active"); // Cacher les boîtes de contenu $(".content").slideUp(); // Pour afficher la boîte de contenu associer, nous // avons modifier le titre du lien par le nom de // l'identifiant de la boite de contenu var contenu_aff = $(this).attr("title"); $("#" + contenu_aff).slideDown(); }); }); </script> </head> <body> <div id="commande"> <form action="#" method="post"> <fieldset>Commande<br/> <ul class="tabs"> <li><a href="#" title="content_1" class="tab active">Café</a></li> <li><a href="#" title="content_2" class="tab">Sandwich</a></li> <li><a href="#" title="content_3" class="tab">Boissons fraîche</a></li> </ul> </fieldset> <div id="content_1" class="content"> <p><table width="100%"> <tr> <td><input type="checkbox" name="choix[]" value="Café noir"> Café noir<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> <td><input type="checkbox" name="choix[]" value="Café au lait"> Café au lait<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> <td><input type="checkbox" name="choix[]" value="Café moka"> Café moka<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> <td><input type="checkbox" name="choix[]" value="Café Crème"> Café Crème<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> </table></p> </div> <div id="content_2" class="content"> <p><table width="100%"> <tr> <td><input type="checkbox" name="choix[]" value="Café noir"> Café noir<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> <td><input type="checkbox" name="choix[]" value="Café au lait"> Café au lait<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> <td><input type="checkbox" name="choix[]" value="Café moka"> Café moka<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> <td><input type="checkbox" name="choix[]" value="Café Crème"> Café Crème<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> </table></p> </div> <div id="content_3" class="content"> <p><table width="100%"> <tr> <td><input type="checkbox" name="choix[]" value="Café noir"> Café noir<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> <td><input type="checkbox" name="choix[]" value="Café au lait"> Café au lait<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> <td><input type="checkbox" name="choix[]" value="Café moka"> Café moka<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> <td><input type="checkbox" name="choix[]" value="Café Crème"> Café Crème<img src="imdesign/tasse-a-cafe-avec-soucoupe.jpg" width="100" height="100" /></td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> <tr> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> <td><input type="checkbox" name="choix[]" value=""> </td> </tr> </table></p> </div> <p><input type="hidden" name="table" value="1" /></p> <p><input type"submit" value="Envoyer" id ="valider"/></p> </form> <div id="message"> <?PHP if(!empty($message)){ echo '<div class="message" style="color:red;text-align:center;"><b>'.$message.'</b></div>'; } ?> </div> <br /> </div> </body> </html>
Partager