2012-04-30 55 views
0

我一直在試圖弄清楚如何編碼我的頁面,以便在我的表單中輸入答案時,它會通過谷歌地圖API搜索該答案。我似乎無法獲得編碼的權利,任何幫助將不勝感激我如何才能實現我的目標!謝謝。使用谷歌地圖API需要幫助

<head> 
     <!-- This is my first trashy online quiz! --> 
      <title>Extra Quiz Information</title> 
</head> 
<body> 
    <h1> More about your quiz results!</h1> 
    <?php 
     if (isset($_COOKIE['visit_id'])){ 
      $visit_id = $_COOKIE['visit_id']; 
      $all_variables = json_decode(file_get_contents("/var/www/html/data/$visit_id.json"), TRUE); 
      //var_dump ($all_variables); 
      echo "<p>"; 
       echo "Our results show that when you took the quiz: What Environment Suits You? on "; echo $all_variables['timestamp']; 
       echo ", <br>you expressed that your favorite place to be in the whole world was: "; echo $all_variables['answer1']; 
      echo "</p>"; 

      $google_map_stuff = json_decode(file_get_contents echo <a href="http://maps.googleapis.com/maps/api/geocode/json?address=', urlencode($all_variables['answer1'])">, TRUE); 
      echo $google_map_stuff["results"][0]["types"][0]; 
      //var_dump($google_map_stuff); 
     } else { 
      echo "You have not yet taken the quiz titled: What Environment Suits You?<br> 
      Please "; echo '<a href="roate1-form.html">take it now</a>'; echo " and then return to this page after you have finished."; 
     } 

       ?> 

</body> 

回答