teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コードを修正

2016/11/08 10:28

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -6,13 +6,24 @@
6
6
 
7
7
  // parse_strで分解処理し、第二引数で配列の変数名を指定
8
8
  parse_str($param, $str);
9
-
9
+
10
10
  // 配列の要素として出力
11
+ $food = http_build_query(array_merge($str,array('business' => 'food')));
12
+ $susi = http_build_query(array_merge($str,array('b_detail' => 'susi')));
13
+ $ramen = http_build_query(array_merge($str,array('b_detail' => 'ramen')));
14
+ $serv = http_build_query(array_merge($str,array('business' => 'serv')));
15
+ $fashion = http_build_query(array_merge($str,array('b_detail' => 'fashion')));
16
+ $clean = http_build_query(array_merge($str,array('b_detail' => 'clean')));
17
+ $kanto = http_build_query(array_merge($str,array('region' => 'kanto')));
18
+ $saitama = http_build_query(array_merge($str,array('area' => 'saitama')));
19
+ $tokyo = http_build_query(array_merge($str,array('area' => 'tokyo')));
20
+ $tohoku = http_build_query(array_merge($str,array('region' => 'tohoku')));
21
+ $miyagi = http_build_query(array_merge($str,array('area' => 'miyagi')));
22
+ $hukusima = http_build_query(array_merge($str,array('area' => 'hukusima')));
23
+
11
- foreach ($str as $key => $value){
24
+ $foodGet = $_GET['business'];
25
+ $servGet = $_GET['business'];
12
- $para .= $key.'='.$value.'&';
26
+ $areaGet = $_GET['region'];
13
- }
14
- $ex_serach = 'http://localhost/url.php?'.$para;
15
- echo $ex_serach;
16
27
  ?>
17
28
  <!DOCTYPE html>
18
29
  <html>
@@ -21,20 +32,47 @@
21
32
  </head>
22
33
  <body>
23
34
  <h1>詳細検索</h1>
35
+ <!--業種で選ぶここから-->
24
36
  <section>
25
- <h2 class="toggle"><a href="http://localhost/url.php?business=food">飲食業</a></h2><!--大カテゴリ-->
37
+ <h2 class="toggle"><a href="http://localhost/url.php?<?php echo $food; ?>">飲食業</a></h2><!--業種大カテゴリ-->
38
+ <?php if($foodGet == 'food'): ?>
39
+ <div class="mini_wrap">
40
+ <p><a href="http://localhost/url.php?<?php echo $susi; ?>">寿司</a></p><!--小カテゴリ-->
41
+ <p><a href="http://localhost/url.php?<?php echo $ramen; ?>">ラーメン</a></p><!--小カテゴリ-->
42
+ </div>
43
+ <?php endif; ?>
44
+ </section>
45
+ <section>
46
+ <h2 class="toggle"><a href="http://localhost/url.php?<?php echo $serv; ?>">サービス</a></h2><!--業種大カテゴリ-->
47
+ <?php if($servGet == 'serv'): ?>
48
+ <div class="mini_wrap">
49
+ <p><a href="http://localhost/url.php?<?php echo $fashion; ?>">ファッション</a></p><!--小カテゴリ-->
50
+ <p><a href="http://localhost/url.php?<?php echo $clean; ?>">クリーニング</a></p><!--小カテゴリ-->
51
+ </div>
52
+ <?php endif; ?>
53
+ </section>
54
+ <!--業種で選ぶここまで-->
55
+
56
+ <!--エリアで選ぶここから-->
57
+ <section>
58
+ <h2 class="toggle"><a href="http://localhost/url.php?<?php echo $kanto; ?>">関東エリア</a></h2><!--エリア大カテゴリ-->
59
+ <?php if($areaGet == 'kanto'): ?>
26
60
  <div class="mini_wrap">
61
+ <p><a href="http://localhost/url.php?<?php echo $saitama; ?>">埼玉</a></p><!--小カテゴリ-->
27
- <p><a href="<?php echo $ex_serach; ?>b_detail=susi">寿司</a></p><!--小カテゴリ-->
62
+ <p><a href="http://localhost/url.php?<?php echo $tokyo; ?>">東京</a></p><!--小カテゴリ-->
28
- <p><a href="<?php echo $ex_serach; ?>b_detail=ramen">ラーメン</a></p><!--小カテゴリ-->
29
63
  </div>
64
+ <?php endif; ?>
30
65
  </section>
31
66
  <section>
32
- <h2 class="toggle"><a href="<?php echo $ex_serach; ?>region=kanto">エリア</a></h2><!--大カテゴリ-->
67
+ <h2 class="toggle"><a href="http://localhost/url.php?<?php echo $tohoku; ?>">東北エリア</a></h2><!--エリア大カテゴリ-->
68
+ <?php if($areaGet == 'tohoku'): ?>
33
69
  <div class="mini_wrap">
34
- <p><a href="<?php echo $ex_serach; ?>area=saitama">埼玉</a></p><!--小カテゴリ-->
70
+ <p><a href="http://localhost/url.php?<?php echo $miyagi; ?>">宮城</a></p><!--小カテゴリ-->
35
- <p><a href="<?php echo $ex_serach; ?>area=tokyo">東京</a></p><!--小カテゴリ-->
71
+ <p><a href="http://localhost/url.php?<?php echo $hukusima; ?>">福島</a></p><!--小カテゴリ-->
36
72
  </div>
73
+ <?php endif; ?>
37
74
  </section>
75
+ <!--エリアで選ぶここまで-->
38
76
  <p><a href="http://localhost/url.php">初期化</a></p>
39
77
  </body>
40
78
  </html>