回答編集履歴
3
調整
test
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
|
65
65
|
```PHP
|
66
66
|
|
67
|
-
<form method="post">
|
67
|
+
<form method="post" action="<?PHP print $_SERVER["SCRIPT_NAME"];?>">
|
68
68
|
|
69
69
|
性別:
|
70
70
|
|
2
追記
test
CHANGED
@@ -55,3 +55,61 @@
|
|
55
55
|
|
56
56
|
|
57
57
|
```
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
# 追記
|
62
|
+
|
63
|
+
sexの他にnameとpageを保持する
|
64
|
+
|
65
|
+
```PHP
|
66
|
+
|
67
|
+
<form method="post">
|
68
|
+
|
69
|
+
性別:
|
70
|
+
|
71
|
+
<select name="sex" required>
|
72
|
+
|
73
|
+
<option value="男">男</option>
|
74
|
+
|
75
|
+
<option value="女">女</option>
|
76
|
+
|
77
|
+
</select>
|
78
|
+
|
79
|
+
<input type="text" name="name">
|
80
|
+
|
81
|
+
<input type="submit" value="検索">
|
82
|
+
|
83
|
+
</form>
|
84
|
+
|
85
|
+
<?PHP
|
86
|
+
|
87
|
+
$param=[];
|
88
|
+
|
89
|
+
$sex=filter_input(INPUT_POST,"sex")?:filter_input(INPUT_GET,"sex");
|
90
|
+
|
91
|
+
if(!is_null($sex)) $param=array_merge($param,["sex"=>$sex]);
|
92
|
+
|
93
|
+
$name=filter_input(INPUT_POST,"name")?:filter_input(INPUT_GET,"name");
|
94
|
+
|
95
|
+
if(!is_null($name)) $param=array_merge($param,["name"=>$name]);
|
96
|
+
|
97
|
+
$page=filter_input(INPUT_GET,"page",FILTER_DEFAULT,["options"=>["default"=>0]]);
|
98
|
+
|
99
|
+
$prev_search=$page>0?("?".http_build_query(array_merge($param,["page"=>$page-1]))):"";
|
100
|
+
|
101
|
+
$next_search="?".http_build_query(array_merge($param,["page"=>$page+1]));
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
if(!is_null($page)){
|
106
|
+
|
107
|
+
if($page>0) print "<a href=\"{$prev_search}\">< 前へ </a>";
|
108
|
+
|
109
|
+
print "<a href=\"{$next_search}\">後ろへ ></a>";
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
?>
|
114
|
+
|
115
|
+
```
|
1
sample
test
CHANGED
@@ -17,3 +17,41 @@
|
|
17
17
|
|
18
18
|
|
19
19
|
が妥当だと思います
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
# sample
|
24
|
+
|
25
|
+
```PHP
|
26
|
+
|
27
|
+
<form method="post">
|
28
|
+
|
29
|
+
性別:
|
30
|
+
|
31
|
+
<select name="sex" required>
|
32
|
+
|
33
|
+
<option value="男">男</option>
|
34
|
+
|
35
|
+
<option value="女">女</option>
|
36
|
+
|
37
|
+
</select>
|
38
|
+
|
39
|
+
<input type="submit" value="検索">
|
40
|
+
|
41
|
+
</form>
|
42
|
+
|
43
|
+
<?PHP
|
44
|
+
|
45
|
+
$sex=filter_input(INPUT_POST,"sex")?:filter_input(INPUT_GET,"sex");
|
46
|
+
|
47
|
+
if(!is_null($sex)){
|
48
|
+
|
49
|
+
print "<a href=\"?sex=".urlencode($sex)."\">".htmlspecialchars($sex)."</a>";
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
?>
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
```
|