質問編集履歴

2

修正しました!!!

2016/11/01 05:57

投稿

aba623ky
aba623ky

スコア63

test CHANGED
File without changes
test CHANGED
@@ -102,6 +102,10 @@
102
102
 
103
103
  $total_count=$xml->results_available;
104
104
 
105
+ if(!$xml->shop){ echo 'No result!!';
106
+
107
+ } else {
108
+
105
109
  ?>
106
110
 
107
111
 
@@ -114,7 +118,11 @@
114
118
 
115
119
  <table border="1">
116
120
 
121
+ <body>
122
+
123
+ <?php foreach($xml->shop as $r){ ?>
124
+
117
- <tr><td>
125
+ <tr><td>
118
126
 
119
127
  <?php echo $r->food->name; ?>
120
128
 

1

phpコードを提示します。

2016/11/01 05:57

投稿

aba623ky
aba623ky

スコア63

test CHANGED
File without changes
test CHANGED
@@ -73,3 +73,69 @@
73
73
  </table>
74
74
 
75
75
  ```
76
+
77
+
78
+
79
+ 自分が作成したphpを表示していなかったので、表示します。
80
+
81
+ まず、パラメータです。
82
+
83
+ ```php
84
+
85
+ <?php
86
+
87
+ $key='私のkey';
88
+
89
+ $count='10';
90
+
91
+ $large_area='Z014';
92
+
93
+ $start =1;
94
+
95
+ $id=$_GET ["id"];
96
+
97
+ $format='xml';
98
+
99
+ $url='http://webservice.recruit.co.jp/hotpepper/gourmet/v1/?key='.$key.'&count='.$count.'&large_area='.$large_area.'&start='.$start.'&id='.$id.'&format='.$format;
100
+
101
+ $xml=simplexml_load_file($url);
102
+
103
+ $total_count=$xml->results_available;
104
+
105
+ ?>
106
+
107
+
108
+
109
+ ```
110
+
111
+ そして、htmlです。
112
+
113
+ ```html
114
+
115
+ <table border="1">
116
+
117
+ <tr><td>
118
+
119
+ <?php echo $r->food->name; ?>
120
+
121
+ </td></tr>
122
+
123
+ <tr><td>
124
+
125
+ <?php echo $r->address; ?>
126
+
127
+ </td></tr>
128
+
129
+ <tr><td>
130
+
131
+ <?php echo $r->open; ?>
132
+
133
+ </td></tr>
134
+
135
+ </table>
136
+
137
+ ```
138
+
139
+ これは検索結果ページです。
140
+
141
+ 店舗詳細ページが作れません。