I seem to be having trouble with the numbers i'm taking out of my mysql database. I figure that my script is considering them to be text string rather than treating them as numbers, but i'm not sure. Any help would be great.
//Connects fine.
//Searchestable and takes out longditude and lattitude for selected postcode fine.
$result = mysql_query("SELECT * FROM postcode WHERE postcode1='ab21'") or die(mysql_error());
$row = mysql_fetch_array($result);
$distance = 10;
$lon = $row[1]; <------ if i use this and only take data from mysql, then i get NO output.
$lat = $row[2];
$lon = -2.21; <---- if i make up some numbers and run them thru' the script i get the output i expect/wanted.
$lat = 52;
if ($distance==10){
$lonMAX = $lon + 0.26;
$lonMIN = $lon - 0.26;
$latMAX = $lat + 0.2;
$latMIN = $lat - 0.2;
}elseif($distance==20){
$latMAX = $lat + 0.2;
$latMIN = $lat - 0.2;
$lonMAX = $lon + 0.26;
$lonMIN = $lon - 0.26;
}
//Search DB again
$result2 = mysql_query("SELECT * FROM postcode WHERE lon BETWEEN {$lonMIN} AND {$lonMAX} AND latt BETWEEN {$latMIN} AND {$latMAX}") or die(mysql_error());
$row2 = mysql_fetch_array($result2);
while($row2 = mysql_fetch_array($result2))
I'm just trying to find the bit that lies between the two values.
I'm sure there is probably an easier way of doing this too, but i've only been learning this stuff for a week, so try not to blow my mind please. Thankyou 😃