回答編集履歴
2
chousei
answer
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
});
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
|
-
<form method="post">
|
|
21
|
+
<form method="post" action="search.php">
|
|
22
22
|
<div class="studentinfo">
|
|
23
23
|
<p><label><input type="checkbox">顧客番号:</label><input type="text" name="id" required></p>
|
|
24
24
|
<p><label><input type="checkbox">担当者:</label><input type="text" name="Staff_Name" required></p>
|
|
@@ -33,4 +33,49 @@
|
|
|
33
33
|
<div>
|
|
34
34
|
<input type="submit" value="検索する">
|
|
35
35
|
</form>
|
|
36
|
+
```
|
|
37
|
+
- search.php
|
|
38
|
+
```PHP
|
|
39
|
+
<?PHP
|
|
40
|
+
$search =filter_input(INPUT_POST,'search');
|
|
41
|
+
$id =filter_input(INPUT_POST,'id');
|
|
42
|
+
$Staff_Name=filter_input(INPUT_POST,'Staff_Name');
|
|
43
|
+
$Status =filter_input(INPUT_POST,'Status');
|
|
44
|
+
$Name =filter_input(INPUT_POST,'Name');
|
|
45
|
+
$Campus =filter_input(INPUT_POST,'Campus');
|
|
46
|
+
$Start_Date=filter_input(INPUT_POST,'Start_Date');
|
|
47
|
+
|
|
48
|
+
if(!is_null($search)){
|
|
49
|
+
$sql ="SELECT * FROM studentinfo WHERE 1 ";
|
|
50
|
+
$data=[];
|
|
51
|
+
if(!is_null($id)){
|
|
52
|
+
$sql.="AND id=? ";
|
|
53
|
+
$data[]=$id;
|
|
54
|
+
}
|
|
55
|
+
if(!is_null($Staff_Name)){
|
|
56
|
+
$sql.="AND Staff_Name LIKE ? ";
|
|
57
|
+
$data[]="%".$Staff_Name."%";
|
|
58
|
+
}
|
|
59
|
+
if(!is_null($Status)){
|
|
60
|
+
$sql.="AND Status=? ";
|
|
61
|
+
$data[]=$Status;
|
|
62
|
+
}
|
|
63
|
+
if(!is_null($Campus)){
|
|
64
|
+
$sql.="AND Name LIKE ? ";
|
|
65
|
+
$data[]="%".$Campus."%";
|
|
66
|
+
}
|
|
67
|
+
if(!is_null($Name)){
|
|
68
|
+
$sql.="AND Name LIKE ? ";
|
|
69
|
+
$data[]="%".$Name."%";
|
|
70
|
+
}
|
|
71
|
+
if(!is_null($Start_Date)){
|
|
72
|
+
$sql.="AND Start_Date=? ";
|
|
73
|
+
$data[]=$Start_Date;
|
|
74
|
+
}
|
|
75
|
+
if(count($data)==0) $sql.="AND 0 ";
|
|
76
|
+
print $sql;
|
|
77
|
+
print_r($data);
|
|
78
|
+
/*実際にはprepare/executeでSQLを発行*/
|
|
79
|
+
}
|
|
80
|
+
?>
|
|
36
81
|
```
|
1
chousei
answer
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
検索条件を指定する場合、送る送らないをクライアント側で調整するところから
|
|
2
2
|
始める必要があるでしょう
|
|
3
3
|
|
|
4
|
+
```javascript
|
|
4
|
-
|
|
5
|
+
<script>
|
|
5
6
|
HTMLElement.prototype.trigger=function(eventStr){
|
|
6
7
|
var e = document.createEvent("HTMLEvents");
|
|
7
8
|
e.initEvent(eventStr, true, true );
|
|
@@ -31,4 +32,5 @@
|
|
|
31
32
|
</div>
|
|
32
33
|
<div>
|
|
33
34
|
<input type="submit" value="検索する">
|
|
34
|
-
</form>
|
|
35
|
+
</form>
|
|
36
|
+
```
|