質問編集履歴
1
phpソースを書き直しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,318 +54,300 @@
|
|
54
54
|
|
55
55
|
'46.txt'=>['name'=>'inp_01','disp'=>'クーピー
|
56
56
|
|
57
|
-
<?php
|
58
|
-
|
59
57
|
$fp = fopen("23.txt", "r"); while ($line = fgets($fp)) {
|
60
58
|
|
61
59
|
echo "$line<br />"; }
|
62
60
|
|
63
|
-
fclose($fp);
|
61
|
+
fclose($fp);'],
|
64
|
-
|
62
|
+
|
65
|
-
'47.txt'=>['name'=>'inp_02','disp'=>'クレヨン
|
63
|
+
'47.txt'=>['name'=>'inp_02','disp'=>'クレヨン
|
66
64
|
|
67
65
|
$fp = fopen("24.txt", "r"); while ($line = fgets($fp)) {
|
68
66
|
|
69
67
|
echo "$line<br />"; }
|
70
68
|
|
71
|
-
fclose($fp);
|
69
|
+
fclose($fp);'],
|
72
|
-
|
70
|
+
|
73
|
-
'48.txt'=>['name'=>'inp_03','disp'=>'マジックペン(大、油性)
|
71
|
+
'48.txt'=>['name'=>'inp_03','disp'=>'マジックペン(大、油性)
|
74
72
|
|
75
73
|
$fp = fopen("24.txt", "r"); while ($line = fgets($fp)) {
|
76
74
|
|
77
75
|
echo "$line<br />"; }
|
78
76
|
|
79
|
-
fclose($fp);
|
77
|
+
fclose($fp);'],
|
80
|
-
|
78
|
+
|
81
|
-
'49.txt'=>['name'=>'inp_04','disp'=>'マジックペン(小、油性)
|
79
|
+
'49.txt'=>['name'=>'inp_04','disp'=>'マジックペン(小、油性)
|
82
80
|
|
83
81
|
$fp = fopen("25.txt", "r"); while ($line = fgets($fp)) {
|
84
82
|
|
85
83
|
echo "$line<br />"; }
|
86
84
|
|
87
|
-
fclose($fp);
|
85
|
+
fclose($fp);'],
|
88
|
-
|
86
|
+
|
89
|
-
'50.txt'=>['name'=>'inp_05','disp'=>'マジックペン(水性)
|
87
|
+
'50.txt'=>['name'=>'inp_05','disp'=>'マジックペン(水性)
|
90
88
|
|
91
89
|
$fp = fopen("26.txt", "r"); while ($line = fgets($fp)) {
|
92
90
|
|
93
91
|
echo "$line<br />"; }
|
94
92
|
|
95
|
-
fclose($fp);
|
93
|
+
fclose($fp); '],
|
96
94
|
|
97
95
|
'51.txt'=>['name'=>'inp_06','disp'=>'マイネーム
|
98
96
|
|
97
|
+
$fp = fopen("27.txt", "r"); while ($line = fgets($fp)) {
|
98
|
+
|
99
|
+
echo "$line<br />"; }
|
100
|
+
|
101
|
+
fclose($fp); '],
|
102
|
+
|
103
|
+
'52.txt'=>['name'=>'inp_07','disp'=>'カッター
|
104
|
+
|
105
|
+
$fp = fopen("28.txt", "r"); while ($line = fgets($fp)) {
|
106
|
+
|
107
|
+
echo "$line<br />"; }
|
108
|
+
|
109
|
+
fclose($fp); '],
|
110
|
+
|
111
|
+
'53.txt'=>['name'=>'inp_08','disp'=>'ハサミ
|
112
|
+
|
113
|
+
$fp = fopen("29.txt", "r"); while ($line = fgets($fp)) {
|
114
|
+
|
115
|
+
echo "$line<br />"; }
|
116
|
+
|
117
|
+
fclose($fp); '],
|
118
|
+
|
119
|
+
'54.txt'=>['name'=>'inp_09','disp'=>'水のり
|
120
|
+
|
121
|
+
$fp = fopen("30.txt", "r"); while ($line = fgets($fp)) {
|
122
|
+
|
123
|
+
echo "$line<br />"; }
|
124
|
+
|
125
|
+
fclose($fp); '],
|
126
|
+
|
127
|
+
'55.txt'=>['name'=>'inp_10','disp'=>'ボンド
|
128
|
+
|
129
|
+
$fp = fopen("31.txt", "r"); while ($line = fgets($fp)) {
|
130
|
+
|
131
|
+
echo "$line<br />"; }
|
132
|
+
|
133
|
+
fclose($fp); '],
|
134
|
+
|
135
|
+
'56.txt'=>['name'=>'inp_11','disp'=>'折り紙
|
136
|
+
|
137
|
+
$fp = fopen("32.txt", "r"); while ($line = fgets($fp)) {
|
138
|
+
|
139
|
+
echo "$line<br />"; }
|
140
|
+
|
141
|
+
fclose($fp); '],
|
142
|
+
|
143
|
+
'57.txt'=>['name'=>'inp_12','disp'=>'かつら
|
144
|
+
|
145
|
+
$fp = fopen("33.txt", "r"); while ($line = fgets($fp)) {
|
146
|
+
|
147
|
+
echo "$line<br />"; }
|
148
|
+
|
149
|
+
fclose($fp);'],
|
150
|
+
|
151
|
+
'58.txt'=>['name'=>'inp_13','disp'=>'ラミネーター
|
152
|
+
|
153
|
+
$fp = fopen("34.txt", "r"); while ($line = fgets($fp)) {
|
154
|
+
|
155
|
+
echo "$line<br />"; }
|
156
|
+
|
157
|
+
fclose($fp); '],
|
158
|
+
|
159
|
+
'59.txt'=>['name'=>'inp_14','disp'=>'ビデオカメラ
|
160
|
+
|
161
|
+
$fp = fopen("35.txt", "r"); while ($line = fgets($fp)) {
|
162
|
+
|
163
|
+
echo "$line<br />"; }
|
164
|
+
|
165
|
+
fclose($fp); '],
|
166
|
+
|
167
|
+
'60.txt'=>['name'=>'inp_15','disp'=>'ガムテープ
|
168
|
+
|
169
|
+
$fp = fopen("36.txt", "r"); while ($line = fgets($fp)) {
|
170
|
+
|
171
|
+
echo "$line<br />"; }
|
172
|
+
|
173
|
+
fclose($fp); '],
|
174
|
+
|
175
|
+
'61.txt'=>['name'=>'inp_16','disp'=>'布テープ
|
176
|
+
|
177
|
+
$fp = fopen("37.txt", "r"); while ($line = fgets($fp)) {
|
178
|
+
|
179
|
+
echo "$line<br />"; }
|
180
|
+
|
181
|
+
fclose($fp); '],
|
182
|
+
|
183
|
+
'62.txt'=>['name'=>'inp_17','disp'=>'スズランテープ(白)
|
184
|
+
|
185
|
+
$fp = fopen("38.txt", "r"); while ($line = fgets($fp)) {
|
186
|
+
|
187
|
+
echo "$line<br />"; }
|
188
|
+
|
189
|
+
fclose($fp); '],
|
190
|
+
|
191
|
+
'63.txt'=>['name'=>'inp_18','disp'=>'スズランテープ(赤)
|
192
|
+
|
193
|
+
$fp = fopen("38.txt", "r"); while ($line = fgets($fp)) {
|
194
|
+
|
195
|
+
echo "$line<br />"; }
|
196
|
+
|
197
|
+
fclose($fp); '],
|
198
|
+
|
199
|
+
'64.txt'=>['name'=>'inp_19','disp'=>'スズランテープ(黄)
|
200
|
+
|
201
|
+
$fp = fopen("39.txt", "r"); while ($line = fgets($fp)) {
|
202
|
+
|
203
|
+
echo "$line<br />"; }
|
204
|
+
|
205
|
+
fclose($fp); '],
|
206
|
+
|
207
|
+
'65.txt'=>['name'=>'inp_20','disp'=>'スズランテープ(緑)
|
208
|
+
|
209
|
+
$fp = fopen("40.txt", "r"); while ($line = fgets($fp)) {
|
210
|
+
|
211
|
+
echo "$line<br />"; }
|
212
|
+
|
213
|
+
fclose($fp); '],
|
214
|
+
|
215
|
+
'66.txt'=>['name'=>'inp_21','disp'=>'スズランテープ(青)
|
216
|
+
|
217
|
+
$fp = fopen("41.txt", "r"); while ($line = fgets($fp)) {
|
218
|
+
|
219
|
+
echo "$line<br />"; }
|
220
|
+
|
221
|
+
fclose($fp); '],
|
222
|
+
|
223
|
+
'67.txt'=>['name'=>'inp_22','disp'=>'スズランテープ(紫)
|
224
|
+
|
225
|
+
$fp = fopen("42.txt", "r"); while ($line = fgets($fp)) {
|
226
|
+
|
227
|
+
echo "$line<br />"; }
|
228
|
+
|
229
|
+
fclose($fp); '],
|
230
|
+
|
231
|
+
'68.txt'=>['name'=>'inp_23','disp'=>'養生テープ
|
232
|
+
|
233
|
+
$fp = fopen("43.txt", "r"); while ($line = fgets($fp)) {
|
234
|
+
|
235
|
+
echo "$line<br />"; }
|
236
|
+
|
237
|
+
fclose($fp); '],
|
238
|
+
|
239
|
+
);
|
240
|
+
|
241
|
+
$msg = array();
|
242
|
+
|
243
|
+
if ($_POST) {
|
244
|
+
|
245
|
+
foreach ($arr as $file=>$val) {
|
246
|
+
|
247
|
+
$name = $val['name'];
|
248
|
+
|
249
|
+
if (!isset($_POST[$name])) die('abort');
|
250
|
+
|
251
|
+
file_put_contents($file, $_POST[$name] . PHP_EOL, LOCK_EX);
|
252
|
+
|
253
|
+
$msg[] = sprintf('%s:%s<br>', $file, htmlspecialchars($_POST[$name], ENT_QUOTES));
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
?>
|
260
|
+
|
261
|
+
<!DOCTYPE HTML >
|
262
|
+
|
263
|
+
<html lang="ja">
|
264
|
+
|
265
|
+
<head>
|
266
|
+
|
267
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js"></script>
|
268
|
+
|
269
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/themes/black/pace-theme-center-circle.min.css" />
|
270
|
+
|
271
|
+
<title>中二1 7月10日 備品ナンバー書き込み</title>
|
272
|
+
|
273
|
+
</head>
|
274
|
+
|
275
|
+
<body>
|
276
|
+
|
277
|
+
<h2>備品ナンバー書き込みフォーム</h2>
|
278
|
+
|
279
|
+
<h3> <?php
|
280
|
+
|
281
|
+
$fp = fopen("class.txt", "r"); while ($line = fgets($fp)) {
|
282
|
+
|
283
|
+
echo "$line<br />"; }
|
284
|
+
|
285
|
+
fclose($fp); ?></h3>
|
286
|
+
|
287
|
+
<h3> <?php
|
288
|
+
|
289
|
+
$fp = fopen("day.txt", "r"); while ($line = fgets($fp)) {
|
290
|
+
|
291
|
+
echo "$line<br />"; }
|
292
|
+
|
293
|
+
fclose($fp); ?>
|
294
|
+
|
295
|
+
</h3>
|
296
|
+
|
297
|
+
<h4>下記のフォームに貸し出した備品のナンバーを書き込んでください。備品名のとなりに貸出申請の個数が記載されています。参考にしてください。複数になる場合は、カンマで区切ってください。</h4>
|
298
|
+
|
299
|
+
<?= count($msg) > 0 ? implode('', $msg) . "備品のナンバーを書き込みました。 <hr>" : '' ?>
|
300
|
+
|
301
|
+
<div style="text-align:center">
|
302
|
+
|
303
|
+
<form action="main.php" method="post">
|
304
|
+
|
99
305
|
<?php
|
100
306
|
|
101
|
-
$fp = fopen("27.txt", "r"); while ($line = fgets($fp)) {
|
102
|
-
|
103
|
-
echo "$line<br />"; }
|
104
|
-
|
105
|
-
fclose($fp); ?>'],
|
106
|
-
|
107
|
-
'52.txt'=>['name'=>'inp_07','disp'=>'カッター<?php
|
108
|
-
|
109
|
-
$fp = fopen("28.txt", "r"); while ($line = fgets($fp)) {
|
110
|
-
|
111
|
-
echo "$line<br />"; }
|
112
|
-
|
113
|
-
fclose($fp); ?>'],
|
114
|
-
|
115
|
-
'53.txt'=>['name'=>'inp_08','disp'=>'ハサミ<?php
|
116
|
-
|
117
|
-
$fp = fopen("29.txt", "r"); while ($line = fgets($fp)) {
|
118
|
-
|
119
|
-
echo "$line<br />"; }
|
120
|
-
|
121
|
-
fclose($fp); ?>'],
|
122
|
-
|
123
|
-
'54.txt'=>['name'=>'inp_09','disp'=>'水のり
|
124
|
-
|
125
|
-
<?php
|
126
|
-
|
127
|
-
$fp = fopen("30.txt", "r"); while ($line = fgets($fp)) {
|
128
|
-
|
129
|
-
echo "$line<br />"; }
|
130
|
-
|
131
|
-
fclose($fp); ?>'],
|
132
|
-
|
133
|
-
'55.txt'=>['name'=>'inp_10','disp'=>'ボンド<?php
|
134
|
-
|
135
|
-
$fp = fopen("31.txt", "r"); while ($line = fgets($fp)) {
|
136
|
-
|
137
|
-
echo "$line<br />"; }
|
138
|
-
|
139
|
-
fclose($fp); ?>'],
|
140
|
-
|
141
|
-
'56.txt'=>['name'=>'inp_11','disp'=>'折り紙<?php
|
142
|
-
|
143
|
-
$fp = fopen("32.txt", "r"); while ($line = fgets($fp)) {
|
144
|
-
|
145
|
-
echo "$line<br />"; }
|
146
|
-
|
147
|
-
fclose($fp); ?>'],
|
148
|
-
|
149
|
-
'57.txt'=>['name'=>'inp_12','disp'=>'かつら
|
150
|
-
|
151
|
-
<?php
|
152
|
-
|
153
|
-
$fp = fopen("33.txt", "r"); while ($line = fgets($fp)) {
|
154
|
-
|
155
|
-
echo "$line<br />"; }
|
156
|
-
|
157
|
-
fclose($fp); ?>'],
|
158
|
-
|
159
|
-
'58.txt'=>['name'=>'inp_13','disp'=>'ラミネーター<?php
|
160
|
-
|
161
|
-
$fp = fopen("34.txt", "r"); while ($line = fgets($fp)) {
|
162
|
-
|
163
|
-
echo "$line<br />"; }
|
164
|
-
|
165
|
-
fclose($fp); ?>'],
|
166
|
-
|
167
|
-
'59.txt'=>['name'=>'inp_14','disp'=>'ビデオカメラ
|
168
|
-
|
169
|
-
<?php
|
170
|
-
|
171
|
-
$fp = fopen("35.txt", "r"); while ($line = fgets($fp)) {
|
172
|
-
|
173
|
-
echo "$line<br />"; }
|
174
|
-
|
175
|
-
fclose($fp); ?>'],
|
176
|
-
|
177
|
-
'60.txt'=>['name'=>'inp_15','disp'=>'ガムテープ<?php
|
178
|
-
|
179
|
-
$fp = fopen("36.txt", "r"); while ($line = fgets($fp)) {
|
180
|
-
|
181
|
-
echo "$line<br />"; }
|
182
|
-
|
183
|
-
fclose($fp); ?>'],
|
184
|
-
|
185
|
-
'61.txt'=>['name'=>'inp_16','disp'=>'布テープ<?php
|
186
|
-
|
187
|
-
$fp = fopen("37.txt", "r"); while ($line = fgets($fp)) {
|
188
|
-
|
189
|
-
echo "$line<br />"; }
|
190
|
-
|
191
|
-
fclose($fp); ?>'],
|
192
|
-
|
193
|
-
'62.txt'=>['name'=>'inp_17','disp'=>'スズランテープ(白)<?php
|
194
|
-
|
195
|
-
$fp = fopen("38.txt", "r"); while ($line = fgets($fp)) {
|
196
|
-
|
197
|
-
echo "$line<br />"; }
|
198
|
-
|
199
|
-
fclose($fp); ?>'],
|
200
|
-
|
201
|
-
'63.txt'=>['name'=>'inp_18','disp'=>'スズランテープ(赤)
|
202
|
-
|
203
|
-
<?php
|
204
|
-
|
205
|
-
$fp = fopen("38.txt", "r"); while ($line = fgets($fp)) {
|
206
|
-
|
207
|
-
echo "$line<br />"; }
|
208
|
-
|
209
|
-
fclose($fp); ?>'],
|
210
|
-
|
211
|
-
'64.txt'=>['name'=>'inp_19','disp'=>'スズランテープ(黄)<?php
|
212
|
-
|
213
|
-
$fp = fopen("39.txt", "r"); while ($line = fgets($fp)) {
|
214
|
-
|
215
|
-
echo "$line<br />"; }
|
216
|
-
|
217
|
-
fclose($fp); ?>'],
|
218
|
-
|
219
|
-
'65.txt'=>['name'=>'inp_20','disp'=>'スズランテープ(緑)<?php
|
220
|
-
|
221
|
-
$fp = fopen("40.txt", "r"); while ($line = fgets($fp)) {
|
222
|
-
|
223
|
-
echo "$line<br />"; }
|
224
|
-
|
225
|
-
fclose($fp); ?>'],
|
226
|
-
|
227
|
-
'66.txt'=>['name'=>'inp_21','disp'=>'スズランテープ(青)
|
228
|
-
|
229
|
-
<?php
|
230
|
-
|
231
|
-
$fp = fopen("41.txt", "r"); while ($line = fgets($fp)) {
|
232
|
-
|
233
|
-
echo "$line<br />"; }
|
234
|
-
|
235
|
-
fclose($fp); ?>'],
|
236
|
-
|
237
|
-
'67.txt'=>['name'=>'inp_22','disp'=>'スズランテープ(紫)
|
238
|
-
|
239
|
-
<?php
|
240
|
-
|
241
|
-
$fp = fopen("42.txt", "r"); while ($line = fgets($fp)) {
|
242
|
-
|
243
|
-
echo "$line<br />"; }
|
244
|
-
|
245
|
-
fclose($fp); ?>'],
|
246
|
-
|
247
|
-
'68.txt'=>['name'=>'inp_23','disp'=>'養生テープ
|
248
|
-
|
249
|
-
<?php
|
250
|
-
|
251
|
-
$fp = fopen("43.txt", "r"); while ($line = fgets($fp)) {
|
252
|
-
|
253
|
-
echo "$line<br />"; }
|
254
|
-
|
255
|
-
fclose($fp); ?>'],
|
256
|
-
|
257
|
-
);
|
258
|
-
|
259
|
-
$msg = array();
|
260
|
-
|
261
|
-
if ($_POST) {
|
262
|
-
|
263
|
-
foreach ($arr as $
|
307
|
+
foreach ($arr as $val) {
|
308
|
+
|
309
|
+
$disp = $val['disp'];
|
264
310
|
|
265
311
|
$name = $val['name'];
|
266
312
|
|
267
|
-
if (!isset($_POST[$name])) die('abort');
|
268
|
-
|
269
|
-
file_put_contents($file, $_POST[$name] . PHP_EOL, LOCK_EX);
|
270
|
-
|
271
|
-
|
313
|
+
printf('%s<br><input type="text" name="%s" value="%s"><br>', $disp, $name, isset($_POST[$name]) ? htmlspecialchars($_POST[$name], ENT_QUOTES) : '');
|
272
314
|
|
273
315
|
}
|
274
316
|
|
317
|
+
?>
|
318
|
+
|
319
|
+
<input type="submit">
|
320
|
+
|
321
|
+
</form>
|
322
|
+
|
323
|
+
</div>
|
324
|
+
|
325
|
+
</body>
|
326
|
+
|
327
|
+
</html>
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
```
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
### 試したこと
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
条件分岐で検索したところ、
|
340
|
+
|
341
|
+
if(条件式){
|
342
|
+
|
343
|
+
条件式がtrueの時の処理
|
344
|
+
|
345
|
+
}else{
|
346
|
+
|
347
|
+
条件式がfalseの時の処理
|
348
|
+
|
275
349
|
}
|
276
350
|
|
277
|
-
?>
|
278
|
-
|
279
|
-
<!DOCTYPE HTML >
|
280
|
-
|
281
|
-
<html lang="ja">
|
282
|
-
|
283
|
-
<head>
|
284
|
-
|
285
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js"></script>
|
286
|
-
|
287
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/themes/black/pace-theme-center-circle.min.css" />
|
288
|
-
|
289
|
-
<title>中二1 7月10日 備品ナンバー書き込み</title>
|
290
|
-
|
291
|
-
</head>
|
292
|
-
|
293
|
-
<body>
|
294
|
-
|
295
|
-
<h2>備品ナンバー書き込みフォーム</h2>
|
296
|
-
|
297
|
-
<h3> <?php
|
298
|
-
|
299
|
-
$fp = fopen("class.txt", "r"); while ($line = fgets($fp)) {
|
300
|
-
|
301
|
-
echo "$line<br />"; }
|
302
|
-
|
303
|
-
fclose($fp); ?></h3>
|
304
|
-
|
305
|
-
<h3> <?php
|
306
|
-
|
307
|
-
$fp = fopen("day.txt", "r"); while ($line = fgets($fp)) {
|
308
|
-
|
309
|
-
echo "$line<br />"; }
|
310
|
-
|
311
|
-
fclose($fp); ?>
|
312
|
-
|
313
|
-
</h3>
|
314
|
-
|
315
|
-
<h4>下記のフォームに貸し出した備品のナンバーを書き込んでください。備品名のとなりに貸出申請の個数が記載されています。参考にしてください。複数になる場合は、カンマで区切ってください。</h4>
|
316
|
-
|
317
|
-
<?= count($msg) > 0 ? implode('', $msg) . "備品のナンバーを書き込みました。 <hr>" : '' ?>
|
318
|
-
|
319
|
-
<div style="text-align:center">
|
320
|
-
|
321
|
-
<form action="main.php" method="post">
|
322
|
-
|
323
|
-
<?php
|
324
|
-
|
325
|
-
foreach ($arr as $val) {
|
326
|
-
|
327
|
-
$disp = $val['disp'];
|
328
|
-
|
329
|
-
$name = $val['name'];
|
330
|
-
|
331
|
-
printf('%s<br><input type="text" name="%s" value="%s"><br>', $disp, $name, isset($_POST[$name]) ? htmlspecialchars($_POST[$name], ENT_QUOTES) : '');
|
332
|
-
|
333
|
-
}
|
334
|
-
|
335
|
-
?>
|
336
|
-
|
337
|
-
<input type="submit">
|
338
|
-
|
339
|
-
</form>
|
340
|
-
|
341
|
-
</div>
|
342
|
-
|
343
|
-
</body>
|
344
|
-
|
345
|
-
</html>
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
```
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
### 試したこと
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
条件分岐で検索したところ、
|
358
|
-
|
359
|
-
if(条件式){
|
360
|
-
|
361
|
-
条件式がtrueの時の処理
|
362
|
-
|
363
|
-
}else{
|
364
|
-
|
365
|
-
条件式がfalseの時の処理
|
366
|
-
|
367
|
-
}
|
368
|
-
|
369
351
|
がヒットしたのですが、
|
370
352
|
|
371
353
|
if文をどこに入れていいのかわかりませんでした。
|