回答編集履歴
3
調整
answer
CHANGED
@@ -195,7 +195,7 @@
|
|
195
195
|
print_r($data);
|
196
196
|
/*
|
197
197
|
$stmt = $pdo->prepare($sql);
|
198
|
-
$stmt->execute(
|
198
|
+
$stmt->execute($data);
|
199
199
|
*/
|
200
200
|
?>
|
201
201
|
<form method="POST">
|
2
調整
answer
CHANGED
@@ -129,7 +129,9 @@
|
|
129
129
|
1や0で処理していたものをvariantに変えました
|
130
130
|
またINをORの羅列に変えました
|
131
131
|
|
132
|
+
※テストのため、以下のソースを適当な名前のphpに保存して実行して下さい
|
132
133
|
```PHP
|
134
|
+
<?PHP
|
133
135
|
$todofuken1=filter_input(INPUT_POST,"todofuken1");
|
134
136
|
$job_type=filter_input(INPUT_POST,"SHOKUSHU_CD",FILTER_DEFAULT,["options"=>["default"=>[]],"flags"=>FILTER_REQUIRE_ARRAY]);
|
135
137
|
$jikyu=filter_input(INPUT_POST,"PAY_START",FILTER_VALIDATE_INT);
|
@@ -195,4 +197,64 @@
|
|
195
197
|
$stmt = $pdo->prepare($sql);
|
196
198
|
$stmt->execute([]);
|
197
199
|
*/
|
200
|
+
?>
|
201
|
+
<form method="POST">
|
202
|
+
<table>
|
203
|
+
<tbody>
|
204
|
+
<tr>
|
205
|
+
<th>勤務地を指定</th>
|
206
|
+
<td>
|
207
|
+
<select name="todofuken1" id="todofuken1">
|
208
|
+
<option value="">都道府県を選択</option>
|
209
|
+
<option value="13">東京都</option>
|
210
|
+
<option value="14">神奈川県</option>
|
211
|
+
<option value="15">埼玉県</option>
|
212
|
+
<option value="16">千葉県</option>
|
213
|
+
</select>
|
214
|
+
</td>
|
215
|
+
</tr>
|
216
|
+
<tr><th>職種を指定</th>
|
217
|
+
<td>
|
218
|
+
<div class="three_line clear">
|
219
|
+
<input type="checkbox" name="SHOKUSHU_CD[]" value="1" id="shokushuLoop1">
|
220
|
+
<label for="shokushuLoop1">オフィスワーク・事務</label>
|
221
|
+
<input type="checkbox" name="SHOKUSHU_CD[]" value="2" id="shokushuLoop2">
|
222
|
+
<label for="shokushuLoop2">営業・販売・サービス</label>
|
223
|
+
<input type="checkbox" name="SHOKUSHU_CD[]" value="3" id="shokushuLoop3">
|
224
|
+
<label for="shokushuLoop3">Web・クリエイティブ</label>
|
225
|
+
</div>
|
226
|
+
</td>
|
227
|
+
</tr>
|
228
|
+
<tr><th>時給を指定</th>
|
229
|
+
<td>
|
230
|
+
<input type="text" class="text_input_s" name="PAY_START" maxlength="8" size="8" value="" style="ime-mode:disabled"> 円以上?
|
231
|
+
</td>
|
232
|
+
</tr>
|
233
|
+
<tr><th>キーワードを指定</th><td><input type="text" class="text_input_l" name="FREE_KEYWORD" maxlength="30" size="20" value="" style="ime-mode:active" placeholder="キーワードを入力してください。"></td></tr>
|
234
|
+
<tr>
|
235
|
+
<th>こだわり条件を指定</th>
|
236
|
+
<td>
|
237
|
+
<div class="accordion_block">
|
238
|
+
<h2 style="background-image: url("../../img/common/icon_arrow_up01.png");">働き方・特徴</h2>
|
239
|
+
<div class="accordion_box three_line clearfix" style="display: block;">
|
240
|
+
<input type="checkbox" name="TOKUCYO[]" value="紹介予定派遣" id="tokucyoLoop1101"><label for="tokucyoLoop1101">紹介予定派遣</label>
|
241
|
+
<input type="checkbox" name="TOKUCYO[]" value="1日7時間未満" id="tokucyoLoop1102"><label for="tokucyoLoop1102">1日7時間未満</label>
|
242
|
+
</div>
|
243
|
+
</div>
|
244
|
+
<div class="accordion_block">
|
245
|
+
<h2 style="background-image: url("../../img/common/icon_arrow_up01.png");">業界</h2>
|
246
|
+
<div class="accordion_box three_line clearfix" style="display: block;">
|
247
|
+
<input type="checkbox" name="GYOUKAI[]" value="マスコミ関連" id="tokucyoLoop3301"><label for="tokucyoLoop3301">マスコミ関連</label>
|
248
|
+
<input type="checkbox" name="GYOUKAI[]" value="金融関連" id="tokucyoLoop3302"><label for="tokucyoLoop3302">金融関連</label>
|
249
|
+
<input type="checkbox" name="GYOUKAI[]" value="流通・サービス関連" id="tokucyoLoop3303"><label for="tokucyoLoop3303">流通・サービス関連</label>
|
250
|
+
<input type="checkbox" name="GYOUKAI[]" value="IT・Web関連" id="tokucyoLoop3304"><label for="tokucyoLoop3304">IT・Web関連</label>
|
251
|
+
</div>
|
252
|
+
</div>
|
253
|
+
</td>
|
254
|
+
</tr>
|
255
|
+
</tbody>
|
256
|
+
</table>
|
257
|
+
<p class="center"><input type="submit" value="この条件で検索する"></p>
|
258
|
+
</form>
|
259
|
+
|
198
260
|
```
|
1
修正・追記
answer
CHANGED
@@ -41,11 +41,11 @@
|
|
41
41
|
}
|
42
42
|
if($flg[3]){
|
43
43
|
$sql.="OR work_type IN (".implode(",",array_fill(0,count($work_type),"?")).") ";
|
44
|
-
$data
|
44
|
+
$data=array_merge($data,$work_type); /*記載ミス訂正*/
|
45
45
|
}
|
46
46
|
if($flg[4]){
|
47
47
|
$sql.="OR gyoukai IN (".implode(",",array_fill(0,count($gyoukai),"?")).") ";
|
48
|
-
$data
|
48
|
+
$data=array_merge($data,$gyoukai); /*記載ミス訂正*/
|
49
49
|
}
|
50
50
|
$sql.=") ";
|
51
51
|
}
|
@@ -123,4 +123,76 @@
|
|
123
123
|
<p class="center"><input type="submit" value="この条件で検索する"></p>
|
124
124
|
</form>
|
125
125
|
|
126
|
+
```
|
127
|
+
※一部記載ミスを訂正しました
|
128
|
+
# より標準SQLらしく
|
129
|
+
1や0で処理していたものをvariantに変えました
|
130
|
+
またINをORの羅列に変えました
|
131
|
+
|
132
|
+
```PHP
|
133
|
+
$todofuken1=filter_input(INPUT_POST,"todofuken1");
|
134
|
+
$job_type=filter_input(INPUT_POST,"SHOKUSHU_CD",FILTER_DEFAULT,["options"=>["default"=>[]],"flags"=>FILTER_REQUIRE_ARRAY]);
|
135
|
+
$jikyu=filter_input(INPUT_POST,"PAY_START",FILTER_VALIDATE_INT);
|
136
|
+
$work_type=filter_input(INPUT_POST,"TOKUCYO",FILTER_DEFAULT,["options"=>["default"=>[]],"flags"=>FILTER_REQUIRE_ARRAY]);
|
137
|
+
$gyoukai=filter_input(INPUT_POST,"GYOUKAI",FILTER_DEFAULT,["options"=>["default"=>[]],"flags"=>FILTER_REQUIRE_ARRAY]);
|
138
|
+
|
139
|
+
$data=[];
|
140
|
+
|
141
|
+
|
142
|
+
$sql ="SELECT * ";
|
143
|
+
$sql.=" FROM kyujin ";
|
144
|
+
$sql.="LEFT JOIN job_type ";
|
145
|
+
$sql.=" ON kyujin.job_type=job_type.id ";
|
146
|
+
$sql.=" LEFT JOIN area ";
|
147
|
+
$sql.=" ON kyujin.area = area.id ";
|
148
|
+
$sql.=" where true ";
|
149
|
+
|
150
|
+
$flg[0]=(!is_null($todofuken1) and $todofuken1!=="");
|
151
|
+
$flg[1]=count($job_type)>0;
|
152
|
+
$flg[2]=$jikyu>0;
|
153
|
+
$flg[3]=count($work_type)>0;
|
154
|
+
$flg[4]=count($gyoukai)>0;
|
155
|
+
|
156
|
+
if($flg[0]){
|
157
|
+
$sql.="AND kyujin.area = ? ";
|
158
|
+
$data[]=$todofuken1;
|
159
|
+
}
|
160
|
+
if($flg[1] or $flg[2] or $flg[3] or $flg[4]){
|
161
|
+
$sql.="AND ( false ";
|
162
|
+
if($flg[1]){
|
163
|
+
foreach($job_type as $val){
|
164
|
+
$sql.="OR kyujin.job_type = ? ";
|
165
|
+
$data[]=$val;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
if($flg[2]){
|
169
|
+
$sql.="OR jikyu>=? ";
|
170
|
+
$data[]=$jikyu;
|
171
|
+
}
|
172
|
+
if($flg[3]){
|
173
|
+
foreach($work_type as $val){
|
174
|
+
$sql.="OR work_type = ? ";
|
175
|
+
$data[]=$val;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
if($flg[4]){
|
179
|
+
foreach($gyoukai as $val){
|
180
|
+
$sql.="OR gyoukai = ? ";
|
181
|
+
$data[]=$val;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
$sql.=") ";
|
185
|
+
}
|
186
|
+
|
187
|
+
if(!in_array(true,$flg)){
|
188
|
+
$sql.="AND false ";
|
189
|
+
}
|
190
|
+
|
191
|
+
print $sql;
|
192
|
+
print "<hr>";
|
193
|
+
print_r($data);
|
194
|
+
/*
|
195
|
+
$stmt = $pdo->prepare($sql);
|
196
|
+
$stmt->execute([]);
|
197
|
+
*/
|
126
198
|
```
|