Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

UK postcode error

Participant ,
Nov 02, 2009 Nov 02, 2009

'm trying to find the miles from km

Everything I try will give me the wrong outcome:

<?php
function calc_postcode_seperation($pcodeA,$pcodeB)

{

// PCODE A

$result=mysql_query("SELECT * FROM postcodes WHERE Pcode='$_REQUEST[postcode]' LIMIT 1");

$row=mysql_fetch_array($result);

$gridn[0]=$row[Grid_N];

$gride[0]=$row[Grid_E];

// PCODE B
$result=mysql_query("SELECT * FROM postcodes LEFT JOIN cars_agents ON postcodes.Pcode = cars_agents.postcode WHERE Pcode='$pcodeB' LIMIT 1");

$row=mysql_fetch_array($result);

$gridn[1]=$row[Grid_N];

$gride[1]=$row[Grid_E];

// TAKE GRID REFS FROM EACH OTHER.

$distance_n=$gridn[0]-$gridn[1];

$distance_e=$gride[0]-$gride[1];

// CALCULATE THE DISTANCE BETWEEN THE TWO POINTS

$hypot=sqrt(($distance_n*$distance_n)+($distance_e*$distance_e));

$text.='Distance between '.$pcodeA.' and '.$pcodeB.' is: '.round($hypot/1000*0.6214/100,2).' Miles Approx';

return $text;

}

//echo calc_postcode_seperation('B7','B21');

?>

TOPICS
Server side applications
438
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 03, 2009 Nov 03, 2009

Have you tried -

(($hypot/1000)*(0.6214/100,2)).  should 100,2 be 100.2?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 05, 2009 Nov 05, 2009
LATEST

Hi,

Even tried that, it still comes up with 3 Miles.

Wolverhampton to Birmingham is not 3 miles

Its about 19-20 miles

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines