回答編集履歴

1

ちょうせい

2021/06/03 02:49

投稿

yambejp
yambejp

スコア116734

test CHANGED
@@ -12,29 +12,27 @@
12
12
 
13
13
  $sql='SELECT * FROM items where 1 ';
14
14
 
15
- if(array_filter([$number,$name,$date],function($x){
15
+ if(count(array_filter([$number,$name,$date],function($x){
16
16
 
17
17
  return !empty($x);
18
18
 
19
- })){
19
+ }))==0){
20
20
 
21
- foreach(["number","name","date"] as $val){
21
+ $sql.=" and 0";
22
22
 
23
- if($$val){
23
+ }
24
24
 
25
- $sql.=" and {$val}=?";
25
+ foreach(["number","name","date"] as $val){
26
26
 
27
- $data[]=$$val;
27
+ if($$val){
28
28
 
29
+ $sql.=" and {$val}=?";
30
+
29
- }
31
+ $data[]=$$val;
30
32
 
31
33
  }
32
34
 
33
- }else{
34
-
35
- $sql.=" and 0";
36
-
37
- };
35
+ }
38
36
 
39
37
  print $sql.";<br>\n";
40
38
 
@@ -57,3 +55,5 @@
57
55
  </form>
58
56
 
59
57
  ```
58
+
59
+ ※一部フローを調整