Gelieve hier te zoeken op uw postcode:

[insert_php] $postcode = $_POST[“postcode”];
if ($postcode != “”)
{
global $wpdb;

$sqlstring = “SELECT Latitude, Longitude, ABS( postcode – ‘”.$postcode.”‘ ) AS distance FROM aa_verkooppunten ORDER BY distance LIMIT 1″;
//echo $sql;
//echo “
“;
$result = $wpdb->get_results($sqlstring);
foreach($result as $row) {
$Lng = $row->Longitude;
$Lat = $row->Latitude;
}

$sql = “SELECT postcode, gemeente, straat, bedrijf, stockprofiel, stocksafe, (2 * (6371 * ATAN2(
SQRT(
POWER(SIN((RADIANS($Lat – `Latitude` ) ) / 2 ), 2 ) +
COS(RADIANS(`Latitude`)) *
COS(RADIANS($Lat )) *
POWER(SIN((RADIANS($Lng – `Longitude` ) ) / 2 ), 2 )
),
SQRT(1-(
POWER(SIN((RADIANS($Lat – `Latitude` ) ) / 2 ), 2 ) +
COS(RADIANS(`Latitude`)) *
COS(RADIANS($Lat)) *
POWER(SIN((RADIANS($Lng – `Longitude` ) ) / 2 ), 2 )
))
)
)) AS distance FROM aa_verkooppunten HAVING distance < 50 ORDER BY distance LIMIT 0 , 5"; //echo $sql; $result = $wpdb->get_results($sql);
echo ‘

‘;
foreach($result as $row) {
echo “

“;
}
echo “

Postcode Gemeente Straat Bedrijf Profiel Stock Safe Stock
“.$row->postcode.” “.$row->gemeente.” “.$row->straat.” “.$row->bedrijf.” “.$row->stockprofiel.” “.$row->stocksafe.”

“;
}
else
{
echo ‘

‘;
}[/insert_php]