Proper usage for the updated ZipCodesRange class is as follows...
Requirements:
- mySQL, PHP
- a mySQL database connection must already be established.
- a database with a zip code column, longitude column, and latitude column must be made. Other information is optional.
- Zip code databases can be found here http://www.cfdynamics.com/cfdynamics/zipbase/index.cfm and other places.
Usage:
<?php
//initialization, pass in DB connection, from zip code, distance in miles.
$zip = new ZipCodesRange($appconf['dbconnection'],'98303',50);
//configuration
$zip->setTableName('zip_codes'); //optional, default is zips.
$zip->setZipColumn('zip'); //optional, default is zip.
$zip->setLonColumn('longitude'); //optional, default is lon.
$zip->setLatColumn('latitude'); //optional, default is lat.
//do the work
$zip->setZipCodesInRange(); //call to initialize zip array
//zip code output, other processing can be done from this array.
$zipArray = $zip->getZipCodesInRange();
echo '<pre>';
print_r($zipArray);
echo '</pre>';
?>
|