質問編集履歴

2

編集前の状態に戻しました

2020/12/10 18:59

投稿

boron
boron

スコア11

test CHANGED
File without changes
test CHANGED
@@ -1,365 +1,89 @@
1
- ID指定の場合
1
+ ![イメージ説明](23d89a759adb1564dffc316b335327ae.png)
2
2
 
3
- ![イメジ説明](acf8b6cb8b5650db3e3095d63540e8d2.jpeg)
3
+ 削除ボタンを押すと次のようなエラが出ます
4
4
 
5
- この画面で削除したい項目を選択した際にURLパラメータとしてID(reservation_id)を渡すことができればいいのではと考えました
5
+ ッセ
6
6
 
7
- こちらのコードは次のようになっています
7
+ Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'year='2020',month='12',day='3',week='木曜日',time1='9',time2='21',g_name='西' at line 1' in C:\eclipse-php\xampp\htdocs\kenkyuu\schedule_delete_done.php on line 31
8
+
9
+
10
+
11
+ schedule_delete_done.phpファイル
8
12
 
9
13
  ```php
10
14
 
11
15
  <!DOCTYPE html>
12
16
 
13
- <html><head>
14
17
 
15
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
16
18
 
17
- <title>スケジュール編集</title>
19
+ <html>
18
20
 
19
- <style>
21
+ <head>
20
22
 
21
- .sun{color: red;}
22
-
23
- .sat{color: blue;}
24
-
25
- #content{
26
-
27
- padding: 20px;
28
-
29
- width: 720px;
30
-
31
- min-height: 490px;
32
-
33
- margin: 0 auto;
34
-
35
- margin-bottom: 10px;
23
+ <meta charset="UTF-8">
36
-
37
- font-size: 153.9%;
38
-
39
- }
40
24
 
41
25
 
42
26
 
43
-
27
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
28
+
29
+ <meta name="viewport" content="width=device-width, initial-scale=1">
30
+
31
+ <title>仮予約</title>
32
+
33
+
34
+
35
+ <style type="text/css">
36
+
37
+
44
38
 
45
39
  </style>
46
40
 
47
41
  </head>
48
42
 
43
+
44
+
49
45
  <body>
50
46
 
51
-
47
+ <?php
52
48
 
53
- <?php
54
-
55
- session_start();
56
-
57
- require("nav_user.php");
58
-
59
- require('dbconnect.php');
49
+ require('dbconnect.php');
60
50
 
61
51
 
62
52
 
63
- $year = date('Y');
64
-
65
- $month = date('m');
66
-
67
- if(isset($_GET["month"])){
68
-
69
- $month = $_GET["month"];
70
-
71
- if(isset($_GET["year"])){
72
-
73
- $year = $_GET["year"];
74
-
75
- if(isset($_GET["btn"])){
76
-
77
- if($_GET["btn"] == 'next'){
78
-
79
- $month = $month+1;
80
-
81
- if($month == 13){
82
-
83
- $month = 1;
84
-
85
- $year = $year+1;
86
-
87
- }
88
-
89
- }elseif($_GET["btn"] == 'prev'){
53
+ $del = $db->prepare('delete from reservation where facility=?,year=?,month=?,day=?,week=?,time1=?,time2=?,g_name=?');
90
-
91
- $month = $month-1;
92
-
93
- if($month == 0){
94
-
95
- $month = 12;
96
-
97
- $year = $year-1;
98
-
99
- }
100
-
101
- }
102
-
103
- }
104
-
105
- }
106
-
107
-
108
-
109
- }
110
54
 
111
55
 
112
56
 
113
- //linkでやる12月の次の処理、linkにyearを追加
57
+ $del->execute(array(
114
58
 
115
- // else{
59
+ $_GET['facility'],
116
60
 
117
- // $month = date('m');
61
+ $_GET['year'],
118
62
 
119
- // }
63
+ $_GET['month'],
120
64
 
121
- // echo $month+1;
65
+ $_GET['day'],
122
66
 
123
- // exit;
67
+ $_GET['week'],
124
68
 
125
-
69
+ $_GET['time1'],
70
+
71
+ $_GET['time2'],
72
+
73
+ $_GET['g_name'],
74
+
75
+ ));
76
+
77
+ print '削除しました';
78
+
79
+ ?>
126
80
 
127
81
 
128
82
 
129
- $reservations = $db->prepare('select * from reservation where year=? and month=?');
83
+ <a href="schedule.php">戻る</a>
130
84
 
131
85
 
132
86
 
133
- $reservations->execute(array(
134
-
135
- $year,$month
136
-
137
- ));
138
-
139
- $monthly=[];//予定が空のときに処理
140
-
141
- while($reservation = $reservations->fetch()){
142
-
143
- $monthly[$reservation['day']][] = array($reservation['time1'],$reservation['time2'],$reservation['g_name']);
144
-
145
- }
146
-
147
- // ksort($monthly);
148
-
149
- // print_r($monthly);
150
-
151
- // print $reservation['time2'];
152
-
153
- // exit;
154
-
155
-
156
-
157
- // 一か月分の日付を曜日付きで出力する
158
-
159
- $lastd = 31;//$yearと$monthから計算して求める
160
-
161
- $time = mktime(0, 0, 0, $month + 1, 0, $year);
162
-
163
- $lastd = date('d',$time);
164
-
165
- //時区間分割を実現する
166
-
167
- $divided=[];
168
-
169
- for ($d=1; $d<= $lastd; $d++){
170
-
171
- if (array_key_exists($d, $monthly)){
172
-
173
- //配列のキーが存在するか調べる(キー、対象の配列)
174
-
175
- //この日に予定があれば、分割していく
176
-
177
- $intv = [[9,21,'']];
178
-
179
- foreach ($monthly[$d] as $yotei){//(対象配列 as その中身)、$yoteiは[x,y,z]
180
-
181
- $intv= div($intv, $yotei);
182
-
183
- }
184
-
185
- $divided[$d] = $intv;//=[x,y,z]
186
-
187
- }else{
188
-
189
- $divided[$d] = [[9,21,'']];
190
-
191
- }
192
-
193
- }
194
-
195
-
196
-
197
- //print_r($divided);
198
-
199
- //exit;
200
-
201
- echo '<div id="content">';
202
-
203
- echo '<table border=1>';
204
-
205
- echo '<h2>スケジュール編集</h2> ';
206
-
207
- // echo '<ul class="nav nav-tabs" role="tablist">
208
-
209
- // <li class="nav-item">
210
-
211
- // <a class="nav-link active" id="item1-tab" data-toggle="tab" href="#item1" role="tab" aria-controls="item1" aria-selected="true">野球場</a>
212
-
213
- // </li>
214
-
215
- // <li class="nav-item">
216
-
217
- // <a class="nav-link" id="item2-tab" data-toggle="tab" href="#item2" role="tab" aria-controls="item2" aria-selected="false">テニスコート</a>
218
-
219
- // </li>
220
-
221
- // </ul>';
222
-
223
- echo "<h3>{$year}年{$month}月</h3>";
224
-
225
- echo "<a class='btn btn-info' href='?year=$year&month=$month&btn=prev'>前月</a>";
226
-
227
- echo "<a class='btn btn-info' href='#'>引き継ぐ</a>";
228
-
229
- echo "<a class='btn btn-info' href='?year=$year&month=$month&btn=next'>次月</a>";
230
-
231
- echo '<tr><td></td>';
232
-
233
- for ($h=9; $h<22; $h++){
234
-
235
- echo '<td >', $h, '</td>';
236
-
237
- }
238
-
239
- echo '</tr>';
240
-
241
- for ($d=1; $d<=$lastd; $d++){
242
-
243
- $time = mktime(0, 0, 0, $month, $d, $year);
244
-
245
- $w = date('w',$time);
246
-
247
- $wdays = array('日','月','火','水','木','金','土',);
248
-
249
- $class = '';
250
-
251
- if ($w==0) $class='sun';
252
-
253
- if ($w==6) $class='sat';
254
-
255
- echo '<tr>';
256
-
257
- echo '<td><span class="'.$class.'">', $d,'('. $wdays[$w].')</span>'. '</td>';
258
-
259
- $yotei = $divided[$d];
260
-
261
- foreach ($yotei as $y){//$yotei=$divided[$d]=[x,y,z]
262
-
263
- $y1 = $y[0];//[x,y,z]のx
264
-
265
- $y2 = $y[1];//[x,y,z]のy
266
-
267
- $y3 = $y[2];//[x,y,z]のz
268
-
269
- $colspan=$y2-$y1+1;
270
-
271
- if(!empty($y3)){
272
-
273
- echo '<td colspan="'. $colspan . '"><a href="schedule_add_delete.php?id='.$reservation['id_reservation'].'y='.$year.'&m='.$month.'&d='.$d.'&w='.$wdays[$w].'&t1='.$y1.'&t2='.$y2.'&facility='.$f.'&gm='.$y3.'">'.$y3.'</a></td>';
274
-
275
- }else{
276
-
277
- echo '<td colspan="'. $colspan . '"><a href="schedule_add_delete.php?y='.$year.'&m='.$month.'&d='.$d.'&w='.$wdays[$w].'&t1='.$y1.'&t2='.$y2.'">○</a></td>';
278
-
279
- }
280
-
281
-
282
-
283
- }
284
-
285
- echo '</tr>';
286
-
287
- }
288
-
289
- echo '</table>';
290
-
291
- echo '</div>';
292
-
293
- ?>
294
-
295
87
  </body>
296
88
 
297
- </html>
298
-
299
- <?php
300
-
301
- //div.phpからコピーしたもの
302
-
303
- function div($intv, $a){
304
-
305
- // $a=[11,12,''] =(div)=> $intv=[[9,10,''],[11,12,'試合'],[13,21,'']]
306
-
307
- $a1 = $a[0];
308
-
309
- $a2 = $a[1];
310
-
311
- $a3 = $a[2];//追加
312
-
313
- $out = [];
314
-
315
- for ($i=0; $i<count($intv); $i++){
316
-
317
- $b1 = $intv[$i][0];
318
-
319
- $b2 = $intv[$i][1];
320
-
321
- $b3 = $intv[$i][2];//追加
322
-
323
-
324
-
325
- if ($a1 >= $b1 and $a2 <= $b2){
326
-
327
- if ($b1<=$a1-1)
328
-
329
- $out[]=[$b1, $a1-1, $b3]; //$b3を追加
330
-
331
- $out[]=[$a1, $a2, $a3]; //$a3を追加
332
-
333
- if ($a2+1<=$b2)
334
-
335
- $out[]=[$a2+1,$b2, $b3]; //$b3を追加
336
-
337
- }else{
338
-
339
- $out[] = $intv[$i];
340
-
341
- }
342
-
343
- }
344
-
345
- return $out;
346
-
347
- }
348
-
349
- ?>
350
-
351
89
  ```
352
-
353
- こちらのコードの
354
-
355
- ```php
356
-
357
- if(!empty($y3)){
358
-
359
- echo '<td colspan="'. $colspan . '"><a href="schedule_add_delete.php?id='.$reservation['id_reservation'].'y='.$year.'&m='.$month.'&d='.$d.'&w='.$wdays[$w].'&t1='.$y1.'&t2='.$y2.'&facility='.$f.'&gm='.$y3.'">'.$y3.'</a></td>';
360
-
361
- }
362
-
363
- ```
364
-
365
- id='.$reservation['id_reservation'].'で値を渡したいと考えているのですが上手くいかないです。

1

ID指定の場合

2020/12/10 18:59

投稿

boron
boron

スコア11

test CHANGED
File without changes
test CHANGED
@@ -1,489 +1,365 @@
1
+ ID指定の場合
2
+
1
- ![イメージ説明](3ba5e71f5b9be32479e830c6a859a4ad.png)
3
+ ![イメージ説明](acf8b6cb8b5650db3e3095d63540e8d2.jpeg)
2
-
3
- ここで削除を押して
4
+
4
-
5
- ![イメージ説明](088a6f5d7da1ec3a2c4d143c665daf04.png)
5
+ この画面で削除したい項目を選択した際にURLパラメータとしてID(reservation_id)を渡すことができればいいのではと考えました
6
-
6
+
7
- タベース該当する値を削除した
7
+ こちらのコドは次のようなって
8
-
9
- 追加・削除画面
10
8
 
11
9
  ```php
12
10
 
11
+ <!DOCTYPE html>
12
+
13
+ <html><head>
14
+
15
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
16
+
17
+ <title>スケジュール編集</title>
18
+
19
+ <style>
20
+
21
+ .sun{color: red;}
22
+
23
+ .sat{color: blue;}
24
+
25
+ #content{
26
+
27
+ padding: 20px;
28
+
29
+ width: 720px;
30
+
31
+ min-height: 490px;
32
+
33
+ margin: 0 auto;
34
+
35
+ margin-bottom: 10px;
36
+
37
+ font-size: 153.9%;
38
+
39
+ }
40
+
41
+
42
+
43
+
44
+
45
+ </style>
46
+
47
+ </head>
48
+
49
+ <body>
50
+
51
+
52
+
53
+ <?php
54
+
55
+ session_start();
56
+
57
+ require("nav_user.php");
58
+
59
+ require('dbconnect.php');
60
+
61
+
62
+
63
+ $year = date('Y');
64
+
65
+ $month = date('m');
66
+
67
+ if(isset($_GET["month"])){
68
+
69
+ $month = $_GET["month"];
70
+
71
+ if(isset($_GET["year"])){
72
+
73
+ $year = $_GET["year"];
74
+
75
+ if(isset($_GET["btn"])){
76
+
77
+ if($_GET["btn"] == 'next'){
78
+
79
+ $month = $month+1;
80
+
81
+ if($month == 13){
82
+
83
+ $month = 1;
84
+
85
+ $year = $year+1;
86
+
87
+ }
88
+
89
+ }elseif($_GET["btn"] == 'prev'){
90
+
91
+ $month = $month-1;
92
+
93
+ if($month == 0){
94
+
95
+ $month = 12;
96
+
97
+ $year = $year-1;
98
+
99
+ }
100
+
101
+ }
102
+
103
+ }
104
+
105
+ }
106
+
107
+
108
+
109
+ }
110
+
111
+
112
+
113
+ //linkでやる12月の次の処理、linkにyearを追加
114
+
115
+ // else{
116
+
117
+ // $month = date('m');
118
+
119
+ // }
120
+
121
+ // echo $month+1;
122
+
123
+ // exit;
124
+
125
+
126
+
127
+
128
+
129
+ $reservations = $db->prepare('select * from reservation where year=? and month=?');
130
+
131
+
132
+
133
+ $reservations->execute(array(
134
+
135
+ $year,$month
136
+
137
+ ));
138
+
139
+ $monthly=[];//予定が空のときに処理
140
+
141
+ while($reservation = $reservations->fetch()){
142
+
143
+ $monthly[$reservation['day']][] = array($reservation['time1'],$reservation['time2'],$reservation['g_name']);
144
+
145
+ }
146
+
147
+ // ksort($monthly);
148
+
149
+ // print_r($monthly);
150
+
151
+ // print $reservation['time2'];
152
+
153
+ // exit;
154
+
155
+
156
+
157
+ // 一か月分の日付を曜日付きで出力する
158
+
159
+ $lastd = 31;//$yearと$monthから計算して求める
160
+
161
+ $time = mktime(0, 0, 0, $month + 1, 0, $year);
162
+
163
+ $lastd = date('d',$time);
164
+
165
+ //時区間分割を実現する
166
+
167
+ $divided=[];
168
+
169
+ for ($d=1; $d<= $lastd; $d++){
170
+
171
+ if (array_key_exists($d, $monthly)){
172
+
173
+ //配列のキーが存在するか調べる(キー、対象の配列)
174
+
175
+ //この日に予定があれば、分割していく
176
+
177
+ $intv = [[9,21,'']];
178
+
179
+ foreach ($monthly[$d] as $yotei){//(対象配列 as その中身)、$yoteiは[x,y,z]
180
+
181
+ $intv= div($intv, $yotei);
182
+
183
+ }
184
+
185
+ $divided[$d] = $intv;//=[x,y,z]
186
+
187
+ }else{
188
+
189
+ $divided[$d] = [[9,21,'']];
190
+
191
+ }
192
+
193
+ }
194
+
195
+
196
+
197
+ //print_r($divided);
198
+
199
+ //exit;
200
+
201
+ echo '<div id="content">';
202
+
203
+ echo '<table border=1>';
204
+
205
+ echo '<h2>スケジュール編集</h2> ';
206
+
207
+ // echo '<ul class="nav nav-tabs" role="tablist">
208
+
209
+ // <li class="nav-item">
210
+
211
+ // <a class="nav-link active" id="item1-tab" data-toggle="tab" href="#item1" role="tab" aria-controls="item1" aria-selected="true">野球場</a>
212
+
213
+ // </li>
214
+
215
+ // <li class="nav-item">
216
+
217
+ // <a class="nav-link" id="item2-tab" data-toggle="tab" href="#item2" role="tab" aria-controls="item2" aria-selected="false">テニスコート</a>
218
+
219
+ // </li>
220
+
221
+ // </ul>';
222
+
223
+ echo "<h3>{$year}年{$month}月</h3>";
224
+
225
+ echo "<a class='btn btn-info' href='?year=$year&month=$month&btn=prev'>前月</a>";
226
+
227
+ echo "<a class='btn btn-info' href='#'>引き継ぐ</a>";
228
+
229
+ echo "<a class='btn btn-info' href='?year=$year&month=$month&btn=next'>次月</a>";
230
+
231
+ echo '<tr><td></td>';
232
+
233
+ for ($h=9; $h<22; $h++){
234
+
235
+ echo '<td >', $h, '</td>';
236
+
237
+ }
238
+
239
+ echo '</tr>';
240
+
241
+ for ($d=1; $d<=$lastd; $d++){
242
+
243
+ $time = mktime(0, 0, 0, $month, $d, $year);
244
+
245
+ $w = date('w',$time);
246
+
247
+ $wdays = array('日','月','火','水','木','金','土',);
248
+
249
+ $class = '';
250
+
251
+ if ($w==0) $class='sun';
252
+
253
+ if ($w==6) $class='sat';
254
+
255
+ echo '<tr>';
256
+
257
+ echo '<td><span class="'.$class.'">', $d,'('. $wdays[$w].')</span>'. '</td>';
258
+
259
+ $yotei = $divided[$d];
260
+
261
+ foreach ($yotei as $y){//$yotei=$divided[$d]=[x,y,z]
262
+
263
+ $y1 = $y[0];//[x,y,z]のx
264
+
265
+ $y2 = $y[1];//[x,y,z]のy
266
+
267
+ $y3 = $y[2];//[x,y,z]のz
268
+
269
+ $colspan=$y2-$y1+1;
270
+
271
+ if(!empty($y3)){
272
+
273
+ echo '<td colspan="'. $colspan . '"><a href="schedule_add_delete.php?id='.$reservation['id_reservation'].'y='.$year.'&m='.$month.'&d='.$d.'&w='.$wdays[$w].'&t1='.$y1.'&t2='.$y2.'&facility='.$f.'&gm='.$y3.'">'.$y3.'</a></td>';
274
+
275
+ }else{
276
+
277
+ echo '<td colspan="'. $colspan . '"><a href="schedule_add_delete.php?y='.$year.'&m='.$month.'&d='.$d.'&w='.$wdays[$w].'&t1='.$y1.'&t2='.$y2.'">○</a></td>';
278
+
279
+ }
280
+
281
+
282
+
283
+ }
284
+
285
+ echo '</tr>';
286
+
287
+ }
288
+
289
+ echo '</table>';
290
+
291
+ echo '</div>';
292
+
293
+ ?>
294
+
295
+ </body>
296
+
297
+ </html>
298
+
13
299
  <?php
14
300
 
15
- session_start();
16
-
17
- require('dbconnect.php');
18
-
19
- require("nav_user.php");
20
-
21
-
22
-
23
- // if(isset($_GET['y']) and isset($_GET['m']) and isset($_GET['d']) and isset($_GET['w']) and isset($_GET['t1']) and isset($_GET['t2']) and isset($_GET['qm'])) {
24
-
25
- // $y = $_GET['y'];
26
-
27
- // $m = $_GET['m'];
28
-
29
- // $d = $_GET['d'];
30
-
31
- // $w = $_GET['w'];
32
-
33
- // $t1 = $_GET['t1'];
34
-
35
- // $t2 = $_GET['t2'];
36
-
37
- // $qm = $_GET['qm'];
38
-
39
- // }
40
-
41
-
42
-
43
- if(isset($_GET['y']))
44
-
45
- {
46
-
47
- $y = $_GET['y'];
48
-
49
- } else {
50
-
51
- $y = null;
52
-
53
- }
54
-
55
- if(isset($_GET['m']))
56
-
57
- {
58
-
59
- $m = $_GET['m'];
60
-
61
- } else {
62
-
63
- $m = null;
64
-
65
- }
66
-
67
- if(isset($_GET['d']))
68
-
69
- {
70
-
71
- $d = $_GET['d'];
72
-
73
- } else {
74
-
75
- $d = null;
76
-
77
- }
78
-
79
- if(isset($_GET['w']))
80
-
81
- {
82
-
83
- $w = $_GET['w'];
84
-
85
- } else {
86
-
87
- $w = null;
88
-
89
- }
90
-
91
- if(isset($_GET['t1']))
92
-
93
- {
94
-
95
- $t1 = $_GET['t1'];
96
-
97
- } else {
98
-
99
- $t1 = null;
100
-
101
- }
102
-
103
- if(isset($_GET['t2']))
104
-
105
- {
106
-
107
- $t2 = $_GET['t2'];
108
-
109
- } else {
110
-
111
- $t2 = null;
112
-
113
- }
114
-
115
- if(isset($_GET['gm']))
116
-
117
- {
118
-
119
- $gm = $_GET['gm'];
120
-
121
- } else {
122
-
123
- $gm = null;
124
-
125
- }
126
-
127
-
128
-
129
- $baseball = '○○野球場';
130
-
131
-
132
-
133
- // $y = filter_input( INPUT_GET, 'y' );
134
-
135
- // $m = filter_input( INPUT_GET, 'm' );
136
-
137
- // $d = filter_input( INPUT_GET, 'd' );
138
-
139
- // $w = filter_input( INPUT_GET, 'w' );
140
-
141
- // $t1 = filter_input( INPUT_GET, 't1' );
142
-
143
- // $t2 = filter_input( INPUT_GET, 't2' );
144
-
145
- // $qm = filter_input( INPUT_GET, 'qm' );
146
-
147
- // echo $qm;
148
-
149
- // exit;
150
-
151
-
152
-
153
- ?>
154
-
155
-
156
-
157
- <!DOCTYPE html>
158
-
159
-
160
-
161
- <html>
162
-
163
- <head>
164
-
165
- <meta charset="UTF-8">
166
-
167
-
168
-
169
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
170
-
171
- <meta name="viewport" content="width=device-width, initial-scale=1">
172
-
173
- <title>追加・削除</title>
174
-
175
-
176
-
177
- <style type="text/css">
178
-
179
-
180
-
181
- </style>
182
-
183
- </head>
184
-
185
-
186
-
187
- <body>
188
-
189
-
190
-
191
- <h2>追加・削除</h2>
192
-
193
-
194
-
195
-
196
-
197
-
198
-
199
- <h3>追加</h3>
200
-
201
- <form action="schedule_branch.php" method="post" enctype="multipart/form-data">
202
-
203
- <input type="button" onclick="history.back()" value="戻る">
204
-
205
- <input type="submit" name="add" value="追加">
206
-
207
-
208
-
209
- <input type="submit" name="delete" value="削除">
210
-
211
-
212
-
213
- <!-- <input type="submit" value="仮予約" /> -->
214
-
215
- <p>施設名<input type="text" name="facility" size="10" value="<?php echo $baseball ;?>"></p>
216
-
217
- <p>使用日<input type="text" name="year" size="2" value="<?php echo $y ;?>">年
218
-
219
- <input type="text" name="month" size="1" value="<?php echo $m ;?>">月
220
-
221
- <input type="text" name="day" size="1" value="<?php echo $d ;?>">日
222
-
223
- <input type="text" name="week" size="4" value="<?php echo $w.'曜日' ;?>">
224
-
225
- </p>
226
-
227
- <p>行事名<input type="text" name="g_name" size="20" value="<?php echo $gm ;?>"></p>
228
-
229
- <p>使用時間</p>
230
-
231
- <select name="time1">
232
-
233
- <?php for($t1;$t1<$t2;$t1++){
234
-
235
- print('<option value="' .$t1. '">' .$t1. ' 時</option> ');
236
-
237
- }
238
-
239
- ?>
240
-
241
- </select>~
242
-
243
-
244
-
245
- <select name="time2">
246
-
247
- <?php for($t2;$t3<$t2;$t2--){
248
-
249
- print('<option value="' .$t2. '">' .$t2. ' 時</option>');
250
-
251
- }
252
-
253
-
254
-
255
- ?>
256
-
257
- </select>
258
-
259
- <table class="table table-striped table-bordered" >
260
-
261
- <tr>
262
-
263
- <?php if($w=='土' || $w=='日') :?>
264
-
265
- <td>土日予約セット</td>
266
-
267
- </tr>
268
-
269
- <tr>
270
-
271
- <td>
272
-
273
- <a href="#" class="btn btn-primary" role="button"><?php
274
-
275
- $e = $d +1;
276
-
277
- echo "{$d}日(土){$e}日(日)" ;?></a>
278
-
279
- </td>
280
-
281
- <?php endif; ?>
282
-
283
- </tr>
284
-
285
- <tr>
286
-
287
- <td>毎週予約セット</td>
288
-
289
- </tr>
290
-
291
- <tr>
292
-
293
- <td>
294
-
295
- <ul>
296
-
297
- <li>
298
-
299
- 土曜日
300
-
301
- <a href="#" class="btn btn-primary" role="button">4日(土)11日(土)18日(土)25日(土)</a>
302
-
303
- </li>
304
-
305
- </td>
306
-
307
- </tr>
308
-
309
- </form>
310
-
311
-
312
-
313
- </table>
314
-
315
-
316
-
317
- </body>
318
-
319
- </html>
320
-
321
-
301
+ //div.phpからコピーしたもの
302
+
303
+ function div($intv, $a){
304
+
305
+ // $a=[11,12,''] =(div)=> $intv=[[9,10,''],[11,12,'試合'],[13,21,'']]
306
+
307
+ $a1 = $a[0];
308
+
309
+ $a2 = $a[1];
310
+
311
+ $a3 = $a[2];//追加
312
+
313
+ $out = [];
314
+
315
+ for ($i=0; $i<count($intv); $i++){
316
+
317
+ $b1 = $intv[$i][0];
318
+
319
+ $b2 = $intv[$i][1];
320
+
321
+ $b3 = $intv[$i][2];//追加
322
+
323
+
324
+
325
+ if ($a1 >= $b1 and $a2 <= $b2){
326
+
327
+ if ($b1<=$a1-1)
328
+
329
+ $out[]=[$b1, $a1-1, $b3]; //$b3を追加
330
+
331
+ $out[]=[$a1, $a2, $a3]; //$a3を追加
332
+
333
+ if ($a2+1<=$b2)
334
+
335
+ $out[]=[$a2+1,$b2, $b3]; //$b3を追加
336
+
337
+ }else{
338
+
339
+ $out[] = $intv[$i];
340
+
341
+ }
342
+
343
+ }
344
+
345
+ return $out;
346
+
347
+ }
348
+
349
+ ?>
322
350
 
323
351
  ```
324
352
 
325
- 削除ボタンを押すとこちらのschedule_baranchを経由して(追加と削除を区別するため)
353
+ こちらのコードの
326
354
 
327
355
  ```php
328
356
 
329
-
330
-
331
- <?php
332
-
333
- require('dbconnect.php');
334
-
335
-
336
-
337
- if(isset($_POST['add']) == true){
338
-
339
-
340
-
341
- $schedule_facility=$_POST['facility'];
342
-
343
- $schedule_year=$_POST['year'];
344
-
345
- $schedule_month=$_POST['month'];
346
-
347
- $schedule_day=$_POST['day'];
348
-
349
- $schedule_week=$_POST['week'];
350
-
351
- $schedule_time1=$_POST['time1'];
352
-
353
- $schedule_time2=$_POST['time2'];
354
-
355
- $schedule_g_name=$_POST['g_name'];
356
-
357
-
358
-
359
- header('Location:schedule_add_done.php?facility='.$schedule_facility.'&year='.$schedule_year.'&month='.$schedule_month.'&day='.$schedule_day.'&week='.$schedule_week.'&time1='.$schedule_time1.'&time2='.$schedule_time2.'&g_name='.$schedule_g_name.'');
360
-
361
- exit();
362
-
363
- }
364
-
365
- if(isset($_POST['delete']) == true){
366
-
367
-
368
-
369
- $schedule_facility=$_POST['facility'];
370
-
371
- $schedule_year=$_POST['year'];
372
-
373
- $schedule_month=$_POST['month'];
374
-
375
- $schedule_day=$_POST['day'];
376
-
377
- $schedule_week=$_POST['week'];
378
-
379
- $schedule_time1=$_POST['time1'];
380
-
381
- $schedule_time2=$_POST['time2'];
382
-
383
- $schedule_g_name=$_POST['g_name'];
384
-
385
-
386
-
387
- header('Location:schedule_delete_done.php?facility='.$schedule_facility.'&year='.$schedule_year.'&month='.$schedule_month.'&day='.$schedule_day.'&week='.$schedule_week.'&time1='.$schedule_time1.'&time2='.$schedule_time2.'&g_name='.$schedule_g_name.'');
388
-
389
- exit();
390
-
391
- }
392
-
393
- ?>
357
+ if(!empty($y3)){
358
+
359
+ echo '<td colspan="'. $colspan . '"><a href="schedule_add_delete.php?id='.$reservation['id_reservation'].'y='.$year.'&m='.$month.'&d='.$d.'&w='.$wdays[$w].'&t1='.$y1.'&t2='.$y2.'&facility='.$f.'&gm='.$y3.'">'.$y3.'</a></td>';
360
+
361
+ }
394
362
 
395
363
  ```
396
364
 
397
- こちらが削除(delete)処理です。
398
-
399
- ```php
400
-
401
- <!DOCTYPE html>
402
-
403
-
404
-
405
- <html>
406
-
407
- <head>
408
-
409
- <meta charset="UTF-8">
410
-
411
-
412
-
413
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
414
-
415
- <meta name="viewport" content="width=device-width, initial-scale=1">
416
-
417
- <title>仮予約</title>
418
-
419
-
420
-
421
- <style type="text/css">
422
-
423
-
424
-
425
- </style>
426
-
427
- </head>
428
-
429
-
430
-
431
- <body>
432
-
433
- <?php
434
-
435
- require('dbconnect.php');
436
-
437
-
438
-
439
- $del = $db->prepare('delete from reservation where facility=?,year=?,month=?,day=?,week=?,time1=?,time2=?,g_name=?');
440
-
441
-
442
-
443
- $del->execute(array(
444
-
445
- $_GET['facility'],
446
-
447
- $_GET['year'],
448
-
449
- $_GET['month'],
450
-
451
- $_GET['day'],
452
-
453
- $_GET['week'],
454
-
455
- $_GET['time1'],
456
-
457
- $_GET['time2'],
458
-
459
- $_GET['g_name'],
460
-
461
- ));
462
-
463
- print '削除しました';
464
-
465
- ?>
466
-
467
-
468
-
469
- <a href="schedule.php">戻る</a>
470
-
471
-
472
-
473
- </body>
474
-
475
- ```
476
-
477
-
478
-
479
- エラーメッセージは
480
-
481
- Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'year='2020',month='12',day='3',week='木曜日',time1='9',time2='21',g_name='西' at line 1' in C:\eclipse-php\xampp\htdocs\kenkyuu\schedule_delete_done.php on line 31
482
-
483
- のように表示されます。
484
-
485
-
486
-
487
- executeする値をg_nameだけにするとエラーなく削除することができますが、行事名だけだと重複する可能性があるのでfacility,year,month,day,week,time1,time2を指定する必要があると考えました。
488
-
489
- どなたか教えていただけないでしょうか?
365
+ id='.$reservation['id_reservation'].'で値を渡したいと考えているのですが上手くいかないです