billy_111 Posted August 12, 2010 Share Posted August 12, 2010 Hi, I don't know how how difficult this is but i need to create a postcode search on the following site: http://www.babiesinthecity.co.uk/sea...ton=&search=M1 What you can see here is a set of "Reviews" which are being pulled out of a database. Each review has a postcode. Now what i need to show on this page is the distance the inputted postcode which is "M1" is to each review. I know i need an API, and i looked into http://code.google.com/apis/maps/documentation/directions/#XML The site is coded in PHP, but i don't quite know how or where to begin? Can anyone point me in the right direction? Thanks Quote Link to comment Share on other sites More sharing options...
kickstart Posted August 13, 2010 Share Posted August 13, 2010 Hi You can get lists of postcodes and grid refernences. Full details lists are expensive but I think you can find free copies linking partial postcodes to grid references (depends how accurate you want it to be). You could possibly do this in javascript but it would seem better to do it on the database when you extract the details for the review. All the best Keith Quote Link to comment Share on other sites More sharing options...
billy_111 Posted August 14, 2010 Author Share Posted August 14, 2010 Thanks! I was actually trying to get the following code to work: public function LoadXml($origin, $destination){ $xml = simplexml_load_file("http://maps.google.com/maps/api/directions/xml?origin=".$origin."&destination=".$destination."&sensor=false"); foreach ($xml->xpath('//distance') as $distance): $lastvalue = $distance->value; endforeach; $total = $lastvalue * 0.00062137119; $total = number_format($total, 2); return $total; } I call the method from the front end like this; $review = Review::searchAllReviewsByTitlePoscodeAndAddress(); while($row = mysql_fetch_array($review)){ $pcode = PostcodeSearch::LoadXML($_GET['search'], $row['postcode']); } But it gives me an error saying it can't recognize "$lastvalue".. Any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.