回答編集履歴

1

調整

2019/07/25 04:31

投稿

yambejp
yambejp

スコア114874

test CHANGED
@@ -6,7 +6,49 @@
6
6
 
7
7
  <?PHP
8
8
 
9
+ $flg=filter_input(INPUT_POST,"flg",FILTER_VALIDATE_INT)===1;
10
+
11
+ $a=filter_input(INPUT_POST,"a");
12
+
13
+ $b=filter_input(INPUT_POST,"b");
14
+
15
+ $c=filter_input(INPUT_POST,"c");
16
+
17
+ if($flg){
18
+
19
+ $sql ="select * from tbl where 1 ";
20
+
21
+ $data=[];
22
+
23
+ if(!is_null($a)){
24
+
25
+ $sql.="and aaa=? ";
26
+
27
+ $data[]=$a;
28
+
29
+ }
30
+
31
+ if(!is_null($b)){
32
+
33
+ $sql.="and bbb=? ";
34
+
35
+ $data[]=$b;
36
+
37
+ }
38
+
39
+ if(!is_null($c)){
40
+
41
+ $sql.="and ccc=? ";
42
+
43
+ $data[]=$c;
44
+
45
+ }
46
+
47
+ print $sql.";<br>\n";
48
+
9
- print_r($_POST);
49
+ print_r($data);
50
+
51
+ }
10
52
 
11
53
  ?>
12
54
 
@@ -30,6 +72,8 @@
30
72
 
31
73
  <form method="post">
32
74
 
75
+ <input type="hidden" name="flg" value="1" >
76
+
33
77
  <label><input type="checkbox">項目A:</label><input type="text" name="a" value="" required disabled><br>
34
78
 
35
79
  <label><input type="checkbox">項目B:</label><input type="text" name="b" value="" required disabled><br>