質問編集履歴

1

情報追記

2017/07/12 01:05

投稿

porusan0880
porusan0880

スコア19

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- PHPで15項目の質問にラジオボタンで選択肢が3つあるフォームを作成しております。
1
+ PHPで10項目の質問にラジオボタンで選択肢が3つあるフォームを作成しております。
2
2
 
3
3
  各質問にかならず一つはチェックを入れるといった感じになります。
4
4
 
@@ -17,3 +17,283 @@
17
17
  よろしくお願いいたします。
18
18
 
19
19
  ちなみに、DBは使用しておりません。
20
+
21
+
22
+
23
+ == form.php ==
24
+
25
+ ```ここに言語を入力
26
+
27
+ <p>各項目に該当する選択肢を選択してください</p>
28
+
29
+ <form action="result.php" method="post">
30
+
31
+ <div class="simulation_area">
32
+
33
+ <dl>
34
+
35
+ <dt>養生数</dt>
36
+
37
+ <dd class="required">
38
+
39
+ <p><input class="validate required" type="radio" id="curing1" value="12000" name="curing_t"><label for="curing1">10t以上</lable></p>
40
+
41
+ <p><input type="radio" id="curing2" value="7000" name="curing_t"><label for="curing2">10~5t以上</lable></p>
42
+
43
+ <p><input type="radio" id="curing3" value="2000" name="curing_t"><label for="curing3">5t以上</lable></p>
44
+
45
+ </dd>
46
+
47
+ </dl>
48
+
49
+
50
+
51
+ <dl>
52
+
53
+ <dt>養生温度</dt>
54
+
55
+ <dd>
56
+
57
+ <p><input class="validate required" type="radio" id="curing4" value="65" name="curing_ond"><label for="curing4">70~60°</lable></p>
58
+
59
+ <p><input type="radio" id="curing5" value="55" name="curing_ond"><label for="curing5">60~50°</lable></p>
60
+
61
+ <p><input type="radio" id="curing6" value="45" name="curing_ond"><label for="curing6">50~40°</lable></p>
62
+
63
+ </dd>
64
+
65
+ </dl>
66
+
67
+
68
+
69
+ <dl>
70
+
71
+ <dt>養生時間</dt>
72
+
73
+ <dd>
74
+
75
+ <p><input class="validate required" type="radio" id="curing7" value="3" name="curing_time"><label for="curing7">5H以上</lable></p>
76
+
77
+ <p><input type="radio" id="curing8" value="2" name="curing_time"><label for="curing8">5~3H</lable></p>
78
+
79
+ </dd>
80
+
81
+ </dl>
82
+
83
+
84
+
85
+ <dl>
86
+
87
+ <dt>養生室の大きさ【間口】</dt>
88
+
89
+ <dd>
90
+
91
+ <p><input class="validate required" type="radio" id="curing9" value="4" name="curing_w"><label for="curing9">3m以上</lable></p>
92
+
93
+ <p><input type="radio" id="curing10" value="2" name="curing_w"><label for="curing10">3~1m</lable></p>
94
+
95
+ </dd>
96
+
97
+ </dl>
98
+
99
+ <dl>
100
+
101
+ <dt>養生室の大きさ【高さ】</dt>
102
+
103
+ <dd>
104
+
105
+ <p><input class="validate required" type="radio" id="curing11" value="4" name="curing_h"><label for="curing11">3m以上</lable></p>
106
+
107
+ <p><input type="radio" id="curing12" value="2" name="curing_h"><label for="curing12">3~1m</lable></p>
108
+
109
+ </dd>
110
+
111
+ </dl>
112
+
113
+ <dl>
114
+
115
+ <dt>養生室の大きさ【長さ】</dt>
116
+
117
+ <dd>
118
+
119
+ <p><input class="validate required" type="radio" id="curing13" value="12" name="curing_l"><label for="curing13">10m以上</lable></p>
120
+
121
+ <p><input type="radio" id="curing14" value="7" name="curing_l"><label for="curing14">10~5m</lable></p>
122
+
123
+ <p><input type="radio" id="curing15" value="2" name="curing_l"><label for="curing15">5m以下</lable></p>
124
+
125
+ </dd>
126
+
127
+ </dl>
128
+
129
+
130
+
131
+ <dl>
132
+
133
+ <dt>養生室の材質</dt>
134
+
135
+ <dd>
136
+
137
+ <p><input class="validate required" type="radio" id="curing16" value="7" name="material"><label for="curing16">シート</lable></p>
138
+
139
+ <p><input type="radio" id="curing17" value="5" name="material"><label for="curing17">ブロック</lable></p>
140
+
141
+ <p><input type="radio" id="curing18" value="3" name="material"><label for="curing18">SUSパネル</lable></p>
142
+
143
+ <p><input type="radio" id="curing19" value="4" name="material"><label for="curing19">FRPパネル</lable></p>
144
+
145
+ </dd>
146
+
147
+ </dl>
148
+
149
+
150
+
151
+ <dl>
152
+
153
+ <dt>燃料</dt>
154
+
155
+ <dd>
156
+
157
+ <p><input class="validate required" type="radio" id="curing20" value="8700,80" name="fuel"><label for="curing20">重油、灯油</lable></p>
158
+
159
+ <p><input type="radio" id="curing21" value="22000,200" name="fuel"><label for="curing21">ガス</lable></p>
160
+
161
+ </dd>
162
+
163
+ </dl>
164
+
165
+
166
+
167
+ <dl>
168
+
169
+ <dt>現在の燃料</dt>
170
+
171
+ <dd>
172
+
173
+ <p><input class="validate required" type="radio" id="curing22" value="12" name="now_fuel"><label for="curing22">10リットル/t以上</lable></p>
174
+
175
+ <p><input type="radio" id="curing23" value="7" name="now_fuel"><label for="curing23">10~5リットル/t</lable></p>
176
+
177
+ <p><input type="radio" id="curing24" value="2" name="now_fuel"><label for="curing24">5リットル/t以下</lable></p>
178
+
179
+ </dd>
180
+
181
+ </dl>
182
+
183
+
184
+
185
+ <dl>
186
+
187
+ <dt>現在の燃料2</dt>
188
+
189
+ <dd>
190
+
191
+ <p><input class="validate required" type="radio" id="curing25" value="7" name="now_fuel2"><label for="curing25">5Nm<span class="sup_text">3</span>/t以上</lable></p>
192
+
193
+ <p><input type="radio" id="curing26" value="4" name="now_fuel2"><label for="curing26">5~3Nm<span class="sup_text">3</span>/t</lable></p>
194
+
195
+ <p><input type="radio" id="curing27" value="2" name="now_fuel2"><label for="curing27">3Nm<span class="sup_text">3</span>/t以下</lable></p>
196
+
197
+ </dd>
198
+
199
+ </dl>
200
+
201
+ <input class="simulation_btn" type="submit" value="結果を表示">
202
+
203
+ </div>
204
+
205
+ </form>
206
+
207
+ ```
208
+
209
+
210
+
211
+ == result.php ==
212
+
213
+ ```ここに言語を入力
214
+
215
+ <?php
216
+
217
+
218
+
219
+ //値を取得
220
+
221
+ $a = $_POST["curing_t"];
222
+
223
+ $b = $_POST["curing_ond"];
224
+
225
+ $c = $_POST["curing_time"];
226
+
227
+ $d = $_POST["curing_w"];
228
+
229
+ $e = $_POST["curing_h"];
230
+
231
+ $f = $_POST["curing_l"];
232
+
233
+ $g = $_POST["material"];
234
+
235
+ $h = explode(',',$_POST["fuel"]);
236
+
237
+ $j = $_POST["now_fuel"];
238
+
239
+ $k = $_POST["now_fuel2"];
240
+
241
+
242
+
243
+ //各計算式に当てはめる
244
+
245
+ $q1 = $a * 0.2 * ($b - 30) * $c;
246
+
247
+ $q2= $a * 0.115 * ($b - 30) * $c;
248
+
249
+
250
+
251
+ // 負荷計算
252
+
253
+ $area_a = $d * $f *2;
254
+
255
+ $area_b = $e * $f *2;
256
+
257
+ $area_c = $d * $e *2;
258
+
259
+ $area = $area_a + $area_b + $area_c;
260
+
261
+ $q3 = $g * $area * ($b-1);
262
+
263
+ $qa = ($q1 + $q2 + $q3) * 1.4;
264
+
265
+
266
+
267
+ // 1tあたりの燃料消費量(スチームチェンヂャー)
268
+
269
+ $qb = $qa / intval($h[0]) / $a * 1000;
270
+
271
+
272
+
273
+ // 効果金額
274
+
275
+ $result = number_format(($j - $qb) * $j * intval($h[1]) * 22 * 12);
276
+
277
+
278
+
279
+ echo $result;
280
+
281
+
282
+
283
+ // データ一覧。
284
+
285
+ $data = array($a, $b, $c, $d, $e, $f, $g, $h[0], $h[1], $j, $k);
286
+
287
+ $ShiftJIS = $data; //文字コードを変えるので、専用の配列を作成してコピー
288
+
289
+ mb_convert_variables('Shift_JIS', 'UTF-8', $ShiftJIS); //文字コードをUTF-8からShiftJISに変更
290
+
291
+ $csv = fopen('file.csv', 'a'); //csvファイルと書き込みモードを指定
292
+
293
+ fputcsv($csv, $ShiftJIS); //変換した配列をcsvファイルに書き込み実行
294
+
295
+ fclose($csv); //csvファイルを閉じる
296
+
297
+ ?>
298
+
299
+ ```