2012-04-30 85 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> 

回答