質問編集履歴
4
編集しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -238,6 +238,8 @@
|
|
238
238
|
|
239
239
|
|
240
240
|
|
241
|
+
```PHP
|
242
|
+
|
241
243
|
<form action="hoge.php" form method="REQUEST">
|
242
244
|
|
243
245
|
|
@@ -445,3 +447,5 @@
|
|
445
447
|
echo '</table>';
|
446
448
|
|
447
449
|
?>
|
450
|
+
|
451
|
+
```
|
3
PHPコードを載せます。
test
CHANGED
File without changes
|
test
CHANGED
@@ -235,3 +235,213 @@
|
|
235
235
|
|
236
236
|
|
237
237
|
```
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
<form action="hoge.php" form method="REQUEST">
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
<input type="radio" name="city" value="04100">仙台市
|
246
|
+
|
247
|
+
<input type="radio" name="city" value="04201">石巻市
|
248
|
+
|
249
|
+
・
|
250
|
+
|
251
|
+
・
|
252
|
+
|
253
|
+
・
|
254
|
+
|
255
|
+
<input type="submit" name="submit" value="送信">
|
256
|
+
|
257
|
+
</form>
|
258
|
+
|
259
|
+
</body>
|
260
|
+
|
261
|
+
<?php
|
262
|
+
|
263
|
+
if ( isset($_REQUEST [ 'my_filter' ] ) ) {$area =$_REQUEST [ 'my_filter' ];$my_page=1;
|
264
|
+
|
265
|
+
} else { if( preg_match( '![0-9]{5}!',$_REQUEST[ 'my_filter' ] ){
|
266
|
+
|
267
|
+
$area =$_REQUEST['my_filter'];
|
268
|
+
|
269
|
+
} else {
|
270
|
+
|
271
|
+
$area = '04110';
|
272
|
+
|
273
|
+
} if ( isset( $_REQUEST[ 'my_page' ] ) && is_numeric($_REQUEST[ 'my_page' ] ) ) {
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
$my_page = absint($_REQUEST[ 'my_page' ] );
|
278
|
+
|
279
|
+
} else {
|
280
|
+
|
281
|
+
$my_page = 1;
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
}
|
286
|
+
|
287
|
+
$id= '私のid';
|
288
|
+
|
289
|
+
$item_per_page = 100;
|
290
|
+
|
291
|
+
$ct = '01';
|
292
|
+
|
293
|
+
$start = ( $my_page - 1) * $item_per_page + 1;
|
294
|
+
|
295
|
+
$url = 'http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid=' . $id . '&ac=' . $area .'&gc='. $ct.'&results=' . $item_per_page . '&start=' . $start . '&detail=full';
|
296
|
+
|
297
|
+
$xml = simplexml_load_file( $url );
|
298
|
+
|
299
|
+
$total_count = $xml->ResultInfo->Total;
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
echo '<table class="left">';
|
304
|
+
|
305
|
+
echo '<caption>' . $start . '件目から' . $item_per_page . '件 表示中 / 総件数 ' . $total_count . '</caption>';
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
echo '<style scoped>.paging, table{width:80%;margin:auto;}td{border-bottom:1px solid #ccc;}td{color:#2980b9;}form{text-align:center;padding:2em;}
|
310
|
+
|
311
|
+
.page-link{padding:1em;margin:.3em;display:inline-block;width:3em;border:1px solid #ccc;word-wrap:normal;}h2{text-align:center;margin:2em 0;}</style>';
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
$html = '<tr><td>%1$s</td><td>%2$s</td><td>%3$s</td><td>%4$s</td><td>%5$s</td><td>%6$s</td><td>%7$s</td></tr>';
|
316
|
+
|
317
|
+
$i = 1; function paging($limit, $page, $disp=5){
|
318
|
+
|
319
|
+
global $area;
|
320
|
+
|
321
|
+
//$dispはページ番号の表示数
|
322
|
+
|
323
|
+
$next = $page+1;
|
324
|
+
|
325
|
+
$prev = $page-1;
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
//ページ番号リンク用
|
330
|
+
|
331
|
+
$start = ($page-floor($disp/2) > 0) ? ($page-floor($disp/2)) : 1;//始点
|
332
|
+
|
333
|
+
$end = ($start > 1) ? ($page+floor($disp/2)) : $disp;//終点
|
334
|
+
|
335
|
+
$start = ($limit < $end)? $start-($end-$limit):$start;//始点再計算
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
if($page != 1 ) {
|
340
|
+
|
341
|
+
print '<a href="?my_page='.$prev.'&name='.$area.'">« 前へ</a>';
|
342
|
+
|
343
|
+
}
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
//最初のページへのリンク
|
348
|
+
|
349
|
+
if($start >= floor($disp/2)){
|
350
|
+
|
351
|
+
print '<a href="?my_page=1&name='.$area.'">1</a>';
|
352
|
+
|
353
|
+
if($start > floor($disp/2)) print "..."; //ドットの表示
|
354
|
+
|
355
|
+
}
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
for($i=$start; $i <= $end ; $i++){//ページリンク表示ループ
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
$class = ($page == $i) ? ' class="current"':"";//現在地を表すCSSクラス
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
if($i <= $limit && $i > 0 )//1以上最大ページ数以下の場合
|
370
|
+
|
371
|
+
print '<a href="?my_page='.$i.'&name='.$area.'"'.$class.'>'.$i.'</a>';//ページ番号リンク表示
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
}
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
//最後のページへのリンク
|
380
|
+
|
381
|
+
if($limit > $end){
|
382
|
+
|
383
|
+
if($limit-1 > $end ) print "..."; //ドットの表示
|
384
|
+
|
385
|
+
print '<a href="?my_page='.$limit.'&name='.$area.'">'.$limit.'</a>';
|
386
|
+
|
387
|
+
}
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
if($page < $limit){
|
392
|
+
|
393
|
+
print '<a href="?my_page='.$next.'&name='.$area.'">次へ »</a>';
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
/*確認用
|
400
|
+
|
401
|
+
print "<p>current:".$page."<br>";
|
402
|
+
|
403
|
+
print "next:".$next."<br>";
|
404
|
+
|
405
|
+
print "prev:".$prev."<br>";
|
406
|
+
|
407
|
+
print "limit:".$limit."<br>";
|
408
|
+
|
409
|
+
print "start:".$start."<br>";
|
410
|
+
|
411
|
+
print "end:".$end."</p>";*/
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
}
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
$limit = 10;//最大ページ数
|
420
|
+
|
421
|
+
$page = empty($_REQUEST ["my_page"])? 1:$_REQUEST["my_page"];//ページ番号
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
paging($limit, $page);
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
foreach ( $xml->Feature as $key => $item ) {
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
printf( $html, $item->Name, $item->Property->Yomi, $item->Property->Tel1, $item->Property->Address, $item->Property->Station->Railway, $item->Property->Station->Name . '駅', $item->Property->Detail->OfficialPcUrl1 );
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
$i++;
|
442
|
+
|
443
|
+
}
|
444
|
+
|
445
|
+
echo '</table>';
|
446
|
+
|
447
|
+
?>
|
2
phpコードを載せます。
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
+
|
10
|
+
|
9
11
|
```html
|
10
12
|
|
11
13
|
|
@@ -44,37 +46,191 @@
|
|
44
46
|
|
45
47
|
|
46
48
|
|
47
|
-
|
49
|
+
```PHP
|
48
50
|
|
49
51
|
<?php
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
53
|
+
if ( isset( $_GET[ 'my_filter' ] ) && preg_match( '![0-9]{5}!', $_GET[ 'my_filter' ] ) ) {
|
54
|
+
|
55
|
+
$area = $_GET[ 'my_filter' ];
|
56
|
+
|
57
|
+
} else {
|
58
|
+
|
59
|
+
$area = '04100';
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
if ( isset( $_GET[ 'my_page' ] ) && is_numeric( $_GET[ 'my_page' ] ) ) {
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
$my_page = absint( $_GET[ 'my_page' ] );
|
68
|
+
|
69
|
+
} else {
|
70
|
+
|
71
|
+
$my_page = 1;
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
$id = 'id';
|
78
|
+
|
79
|
+
$item_per_page = 50;
|
80
|
+
|
81
|
+
$start = ( $my_page - 1) * $item_per_page + 1;
|
82
|
+
|
83
|
+
$url = 'http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid=' . $id . '&ac=' . $area . '&results=' . $item_per_page . '&start=' . $start . '&detail=full';
|
84
|
+
|
85
|
+
$xml = simplexml_load_file( $url );
|
86
|
+
|
87
|
+
$total_count = $xml->ResultInfo->Total;
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
echo '<table class="left">';
|
92
|
+
|
93
|
+
echo '<caption>' . $start . '件目から' . $item_per_page . '件 表示中 / 総件数 ' . $total_count . '</caption>';
|
94
|
+
|
95
|
+
echo '<style scoped>.paging, table{width:80%;margin:auto;}td{border-bottom:1px solid #ccc;}td{color:#2980b9;}form{text-align:center;padding:2em;}
|
96
|
+
|
97
|
+
.page-link{padding:1em;margin:.3em;display:inline-block;width:3em;border:1px solid #ccc;word-wrap:normal;}h2{text-align:center;margin:2em 0;}</style>';
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
$html = '<tr><td>%1$s</td><td>%2$s</td><td>%3$s</td><td>%4$s</td><td>%5$s</td><td>%6$s</td><td>%7$s</td></tr>';
|
102
|
+
|
103
|
+
$i = 1;
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
function paging($limit, $page, $disp=5){
|
108
|
+
|
109
|
+
global $area;
|
110
|
+
|
111
|
+
//$dispはページ番号の表示数
|
112
|
+
|
113
|
+
$next = $page+1;
|
114
|
+
|
115
|
+
$prev = $page-1;
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
//ページ番号リンク用
|
120
|
+
|
121
|
+
$start = ($page-floor($disp/2) > 0) ? ($page-floor($disp/2)) : 1;//始点
|
122
|
+
|
123
|
+
$end = ($start > 1) ? ($page+floor($disp/2)) : $disp;//終点
|
124
|
+
|
125
|
+
$start = ($limit < $end)? $start-($end-$limit):$start;//始点再計算
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
if($page != 1 ) {
|
130
|
+
|
131
|
+
print '<a href="?my_page='.$prev.'&my_filter='.$area.'">« 前へ</a>';
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
//最初のページへのリンク
|
138
|
+
|
139
|
+
if($start >= floor($disp/2)){
|
140
|
+
|
141
|
+
print '<a href="?my_page=1&my_filter='.$area.'">1</a>';
|
142
|
+
|
143
|
+
if($start > floor($disp/2)) print "..."; //ドットの表示
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
for($i=$start; $i <= $end ; $i++){//ページリンク表示ループ
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
$class = ($page == $i) ? ' class="current"':"";//現在地を表すCSSクラス
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
if($i <= $limit && $i > 0 )//1以上最大ページ数以下の場合
|
160
|
+
|
161
|
+
print '<a href="?my_page='.$i.'&my_filter='.$area.'"'.$class.'>'.$i.'</a>';//ページ番号リンク表示
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
//最後のページへのリンク
|
170
|
+
|
171
|
+
if($limit > $end){
|
172
|
+
|
173
|
+
if($limit-1 > $end ) print "..."; //ドットの表示
|
174
|
+
|
175
|
+
print '<a href="?my_page='.$limit.'&my_filter='.$area.'">'.$limit.'</a>';
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
if($page < $limit){
|
182
|
+
|
183
|
+
print '<a href="?my_page='.$next.'&my_filter='.$area.'">次へ »</a>';
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
/*確認用
|
190
|
+
|
191
|
+
print "<p>current:".$page."<br>";
|
192
|
+
|
193
|
+
print "next:".$next."<br>";
|
194
|
+
|
195
|
+
print "prev:".$prev."<br>";
|
196
|
+
|
197
|
+
print "limit:".$limit."<br>";
|
198
|
+
|
199
|
+
print "start:".$start."<br>";
|
200
|
+
|
201
|
+
print "end:".$end."</p>";*/
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
$limit = 10;//最大ページ数
|
210
|
+
|
211
|
+
$page = empty($_GET["my_page"])? 1:$_GET["my_page"];//ページ番号
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
paging($limit, $page);
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
foreach ( $xml->Feature as $key => $item ) {
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
printf( $html, $item->Name, $item->Property->Yomi, $item->Property->Tel1, $item->Property->Address, $item->Property->Station->Railway, $item->Property->Station->Name . '駅', $item->Property->Detail->OfficialPcUrl1 );
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
$i++;
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
echo '</table>';
|
232
|
+
|
233
|
+
?>
|
78
234
|
|
79
235
|
|
80
236
|
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
わからない部分は、if(issetの後に何を書けばいいかわかりません。
|
4
4
|
|
5
|
-
今、美味しいうどんが食べたいみたいに北海道のラジオボタンをクリックしたら北海道のうどんやが表示されるようにしたいのですが詳しいやり方がわかりません。下記にhtmlとphpコードを書きましたが、間違いはありますか?
|
5
|
+
今、美味しいうどんが食べたいみたいに北海道のラジオボタンをクリックしたら北海道のうどんやが表示されるようにしたいのですが詳しいやり方がわかりません。下記にhtmlとphpコードを書きましたが、間違いはありますか?また、htmlとphpのコードの二つはradioForm.phpに書くのですか?
|
6
6
|
|
7
7
|
|
8
8
|
|