回答編集履歴

2

調整

2016/08/30 09:31

投稿

yambejp
yambejp

スコア114843

test CHANGED
@@ -95,3 +95,137 @@
95
95
  ?>
96
96
 
97
97
  ```
98
+
99
+
100
+
101
+ #追記
102
+
103
+ ```PHP
104
+
105
+ <?php
106
+
107
+
108
+
109
+ //初期設定
110
+
111
+ $selected["budget"]=array_fill_keys(["B001","B002","B003"],'');
112
+
113
+ $selected["food"]=array_fill_keys(["R031","R032"],'');
114
+
115
+ $selected["credit_card"]=array_fill_keys(["c01","c02"],'');
116
+
117
+
118
+
119
+ //値セット
120
+
121
+ $budget=filter_input(INPUT_GET,"budget",FILTER_DEFAULT,["options"=>["default"=>""]]);
122
+
123
+ $food=filter_input(INPUT_GET,"food",FILTER_DEFAULT,["options"=>["default"=>""]]);
124
+
125
+ $credit_card=filter_input(INPUT_GET,"credit_card",FILTER_DEFAULT,["options"=>["default"=>""]]);
126
+
127
+
128
+
129
+ $selected["budget"][$budget]=" selected";
130
+
131
+ $selected["food"][$food]=" selected";
132
+
133
+ $selected["credit_card"][$credit_card]=" selected";
134
+
135
+
136
+
137
+ $param="";
138
+
139
+
140
+
141
+ if($budget!==""){
142
+
143
+ $param.=($param==="")?"?":"&";
144
+
145
+ $param.="budget=".urlencode($budget);
146
+
147
+ }
148
+
149
+ if(!in_array("",[$food,$credit_card])){
150
+
151
+ $param.=($param==="")?"?":"&";
152
+
153
+ $param.="food=".urlencode($food)."&credit_card=".urlencode($credit_card);
154
+
155
+ }
156
+
157
+ if($budget!=="" || !in_array("",[$food,$credit_card])){
158
+
159
+ $url="http://webservice.recruit.co.jp/hotpepper/gourmet/v1/".$param;
160
+
161
+ print $url."<br>";
162
+
163
+ }
164
+
165
+ print <<<eof
166
+
167
+ <html>
168
+
169
+ <head>
170
+
171
+ <title>API_SAMPLE</title>
172
+
173
+ </head>
174
+
175
+ <body>
176
+
177
+ <form method="GET">
178
+
179
+ <select name="budget">
180
+
181
+ <option value="">=== 選択して ===</option>
182
+
183
+ <option value="B001"{$selected["budget"]["B001"]}>~2000円</option>
184
+
185
+ <option value="B002"{$selected["budget"]["B002"]}>2001円~3000円</option>
186
+
187
+ <option value="B003"{$selected["budget"]["B003"]}>3001円~4000円</option>
188
+
189
+ </select>
190
+
191
+ <input type="submit" name="search" value="検索">
192
+
193
+ </form>
194
+
195
+ <form method="GET">
196
+
197
+ <select name="food">
198
+
199
+ <option value="">=== 選択して ===</option>
200
+
201
+ <option value="R031"{$selected["food"]["R031"]}>ステーキ</option>
202
+
203
+ <option value="R032"{$selected["food"]["R032"]}>カレー・ハヤシライス</option>
204
+
205
+ </select>
206
+
207
+ <select name="credit_card">
208
+
209
+ <option value="">=== 選択して ===</option>
210
+
211
+ <option value="c01"{$selected["credit_card"]["c01"]}>VISA</option>
212
+
213
+ <option value="c02"{$selected["credit_card"]["c02"]}>マスター</option>
214
+
215
+ </select>
216
+
217
+ <input type="submit" name="search" value="検索">
218
+
219
+ </form>
220
+
221
+ </body>
222
+
223
+ </html>
224
+
225
+ eof;
226
+
227
+
228
+
229
+ ?>
230
+
231
+ ```

1

修正

2016/08/30 09:31

投稿

yambejp
yambejp

スコア114843

test CHANGED
@@ -44,6 +44,8 @@
44
44
 
45
45
  <select name="budget">
46
46
 
47
+ <option value="">=== 選択して ===</option>
48
+
47
49
  <option value="B001"{$selected["budget"]["B001"]}>?2000円</option>
48
50
 
49
51
  <option value="B002"{$selected["budget"]["B002"]}>2001円?3000円</option>
@@ -52,7 +54,15 @@
52
54
 
53
55
  </select>
54
56
 
57
+ <input type="submit" name="search" value="検索">
58
+
59
+ </form>
60
+
61
+ <form method="GET">
62
+
55
63
  <select name="food">
64
+
65
+ <option value="">=== 選択して ===</option>
56
66
 
57
67
  <option value="R031"{$selected["food"]["R031"]}>ステーキ</option>
58
68
 
@@ -62,11 +72,15 @@
62
72
 
63
73
  <select name="credit_card">
64
74
 
75
+ <option value="">=== 選択して ===</option>
76
+
65
77
  <option value="c01"{$selected["credit_card"]["c01"]}>VISA</option>
66
78
 
67
79
  <option value="c02"{$selected["credit_card"]["c02"]}>マスター</option>
68
80
 
81
+ </select>
82
+
69
- </select> <input type="submit" name="search" value="検索">
83
+ <input type="submit" name="search" value="検索">
70
84
 
71
85
  </form>
72
86