質問編集履歴

1

問題コード部分以外の関係ない部分の削除

2017/12/19 00:42

投稿

mashumaro0628
mashumaro0628

スコア19

test CHANGED
File without changes
test CHANGED
@@ -24,163 +24,7 @@
24
24
 
25
25
  ```ここに言語を入力
26
26
 
27
- <?php
28
-
29
-
30
-
31
- $alp_array=array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
32
-
33
- $table_array=array();
34
-
35
- /////////セッション//////////
36
-
37
-
38
-
39
- //テーブル保存用
40
-
41
- if(isset($_SESSION['table'])){
42
-
43
- }else{
44
-
45
- $_SESSION['table']=null;
46
-
47
- }
48
-
49
-
50
-
51
- //ドロップダウンリスト保存用
52
-
53
- if(isset($_SESSION['select'])){
54
-
55
- }else{
56
-
57
- $_SESSION['select']=null;
58
-
59
- }
60
-
61
-
62
-
63
- //花名保存用
64
-
65
- if(isset($_SESSION['f_name'])){
66
-
67
- }else{
68
-
69
- $_SESSION['f_name']=null;
70
-
71
- }
72
-
73
-
74
-
75
- //種別保存用
76
-
77
- if(isset($_SESSION['f_catename'])){
78
-
79
- }else{
80
-
81
- $_SESSION['f_catename']=null;
82
-
83
- }
84
-
85
-
86
-
87
- //セッション削除
88
-
89
- if(isset($_POST['destroy'])){
90
-
91
- session_destroy();
92
-
93
- }
94
-
95
-
96
-
97
- ////////データベース////////
98
-
99
-
100
-
101
- //PDO接続
102
-
103
- $pdo = new PDO("mysql:dbname=flower_shop;host=localhost","root","admin");
104
-
105
-
106
-
107
- //商品マスタ表示
108
-
109
- $stmt1 = $pdo->query("select p_masta.P_code,p_masta.P_categorycode,p_codes.p_name,p_masta.p_catename from p_masta LEFT OUTER JOIN p_codes on p_masta.P_code = p_codes.P_code");
110
-
111
- $_SESSION['table'].='<table border="1">';
112
-
113
- $_SESSION['table'].="<tr><td>商品コード</td><td>商品種類</td><td>商品</td></tr>";
114
-
115
- $_SESSION['table'].="</tr>";
116
-
117
- foreach ($stmt1 as $key) {
118
-
119
- $_SESSION['table'].="<tr>";
120
-
121
- $_SESSION['table'].="<td>".$key['P_code'].$key['P_categorycode']."</td>";
122
-
123
- $_SESSION['table'].="<td>".$key['p_name']."</td>";
124
-
125
- $_SESSION['table'].="<td>".$key['p_catename']."</td>";
126
-
127
- $_SESSION['table'].="</tr>";
128
-
129
- }
130
-
131
- $_SESSION['table'].='</table>';
132
-
133
-
134
-
135
- //商品名のみ追加→商品コード割り振り
136
-
137
- if(isset($_POST['flower_name'])){
138
-
139
- $stmt2 = $pdo->query("select P_code from p_code ORDER BY P_code");
140
-
141
- $new_Pcode=array(); //新しい商品コード、生成、取り扱い用配列
142
-
143
- foreach ($stmt2 as $key) {
144
-
145
- if($key['P_code']==null){
146
-
147
- $new_Pcode = str_split($key['P_code-1']);
148
-
149
- }
150
-
151
- }
152
-
153
- }
154
-
155
-
156
-
157
- //配列に商品名を入れる
158
-
159
- if(isset($_POST['flower_name'])){
160
-
161
- $stmt2 = $pdo->query("select P_code from p_code ORDER BY P_code");
162
-
163
- $new_Pcode=array(); //新しい商品コード、生成、取り扱い用配列
164
-
165
- foreach ($stmt2 as $key) {
166
-
167
- if($key['P_code']==null){
168
-
169
- $new_Pcode = str_split($key['P_code-1']);
170
-
171
- }
172
-
173
- }
174
-
175
- }
176
-
177
-
178
-
179
- ?>
180
-
181
-
182
-
183
- <!DOCTYPE html>
27
+ <<!DOCTYPE html>
184
28
 
185
29
  <html>
186
30
 
@@ -190,77 +34,49 @@
190
34
 
191
35
  <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
192
36
 
37
+ <script type="text/javascript" src="js/main.js"></script>
38
+
193
39
  <script type="text/javascript">
194
40
 
195
41
  msg="";
196
42
 
197
43
  $(function(){
198
44
 
199
- $('#add_product_inp').click(function(){
45
+ $('#add_product_frm').keyup(function(e){
200
46
 
201
- $('#add_cateproduct_div').css('display','none');
47
+ var fd=new FormData($(this).get(0));
202
48
 
203
- $('#add_product_div').css('display','block');
204
-
205
- //td_val=$(this).text();
206
-
207
- //$('#selected_fname').val([td_val]);
208
-
209
- //$('#selected_form').submit();
210
-
211
- });
212
-
213
- $('#add_cateproduct_inp').click(function(){
214
-
215
- $('#add_product_div').css('display','none');
216
-
217
- $('#add_cateproduct_div').css('display','block');
218
-
219
- //td_val=$(this).text();
220
-
221
- //$('#selected_fname').val([td_val]);
222
-
223
- //$('#selected_form').submit();
224
-
225
- });
226
-
227
- $('#add_product_frm').keyup(function(e){
228
-
229
- var fd=new FormData($(this).get(0));
49
+ msg="";
230
50
 
231
51
  $.ajax({
232
52
 
233
- "url":"select.php",
53
+ "url":"select.php",
234
54
 
235
- "data":fd,
55
+ "data":fd,
236
56
 
237
- "type":"post",
57
+ "type":"post",
238
58
 
239
- "processData": false,
59
+ "processData": false,
240
60
 
241
- "contentType": false,
61
+ "contentType": false,
242
62
 
243
63
  }).done(function(response){
244
64
 
245
- res=response;
246
-
247
- afterAjax();
65
+ afterAjax(response);
248
66
 
249
67
  });
250
68
 
251
69
  e.preventDefault();
252
70
 
253
- function afterAjax(){
71
+ function afterAjax(response){
254
72
 
255
- msg=res;
73
+ msg=response;
256
74
 
257
- }
75
+ }
258
76
 
259
77
  });
260
78
 
261
- });
79
+ });
262
-
263
-
264
80
 
265
81
  </script>
266
82
 
@@ -278,11 +94,11 @@
278
94
 
279
95
  <form id="add_product_frm" action="masta_add.php" method="post">
280
96
 
281
- <input name="cate_serch_inp" id="cate_sercxch_inp" type="text" placeholder="商品の種類を選択" autocomplete="off" required><br>
97
+ <input name="cate_serch_inp" id="cate_sercxch_inp" type="text" placeholder="商品の種類を選択" autocomplete="off" required><br>
282
98
 
283
- <script type="text/javascript">
99
+ <script type="text/javascript">
284
100
 
285
- console.log(msg);
101
+ console.log(msg);
286
102
 
287
103
  /*document.write("<select>");
288
104
 
@@ -294,9 +110,9 @@
294
110
 
295
111
  document.write("</select>");*/
296
112
 
297
- </script>
113
+ </script>
298
114
 
299
- <input name="" placeholder="商品名を入力" autocomplete="off" required><input id="submit" type="submit" value="追加">
115
+ <input name="" placeholder="商品名を入力" autocomplete="off" required><input id="submit" type="submit" value="追加">
300
116
 
301
117
  </form>
302
118
 
@@ -354,6 +170,10 @@
354
170
 
355
171
 
356
172
 
173
+
174
+
175
+
176
+
357
177
  ```
358
178
 
359
179