Location: PHPKode > scripts > AzDGZIP > azdgzip/test_zip.php
<?php
include_once('ZIPLocator.php');
@mysql_connect('localhost', 'user', 'password') or die("Can`t connect to server<br>Your mysql login or mysql password is wrong.");
@mysql_select_db('database') or die("Can`t connect to server<br>Database doesn`t exist");

// Install Table before run it.
$zip = new ZIPLocator('pro_zip_data');

$zip1 = 12345;
$zip2 = 23456;

$distance = $zip->distance($zip1,$zip2);

echo 'The distance between <b>'.$zip1.'</b> and <b>'.$zip2.'</b> is <b>'.$distance.'</b> Miles<br><br>';

$radius = 20;
$zips = $zip->inradius($zip1,$radius);
$tmp = implode(', ',$zips);
echo 'There are <b>'.count($zips).'</b> Zip codes within <b>'.$radius.'</b> Miles of <b>'.$zip1.'</b>:<br><br>';

echo '<b>Example Query to find all users within 20 miles</b>: <br>mysql_query("Select * FROM <b>YourTableName</b> Where <b>YourZipField</b> IN ('.$tmp.')")';
?>
Return current item: AzDGZIP