zip codes
i'm doing a project where i need to measure distances between zip codes; en route to a solution i stumbled upon a couple of handy resources that i figured i'd pass along:
http://www.zend.com/codex.php?id=1486&single=1
a class used to do various zipcode calculations such as distance and finding the zip codes within range of another zip code
take a look at the class to see how he wants your tables and fields named for the state and zip code database tables
http://www.cfdynamics.com/cfdynamics/zipbase/index.cfm
zipbase - datbase of zip codes with lat & long info, state info, etc. available in a text file and an access datbase
i used the textfile and in mysql said:
mysql> LOAD DATA LOCAL INFILE 'c:/ZIP_CODES.txt'
-> INTO TABLE zip_code
-> FIELDS TERMINATED BY ',' ENCLOSED BY '"'
-> LINES TERMINATED BY '\r\n';
http://27.org/isocountrylist/usps_states_list.sql
SQL file for creating a states table (i believe in the zipcode class, he wants the states table called "state")
i used that to make a silly little app to test some of the features of the class:
oh, and i found this http://centricle.com/tools/html-entities/ to convert app code into HTML special chars
crossposted in
php
mysql &
bobalien
http://www.zend.com/codex.php?id=1486&single=1
a class used to do various zipcode calculations such as distance and finding the zip codes within range of another zip code
take a look at the class to see how he wants your tables and fields named for the state and zip code database tables
http://www.cfdynamics.com/cfdynamics/zipbase/index.cfm
zipbase - datbase of zip codes with lat & long info, state info, etc. available in a text file and an access datbase
i used the textfile and in mysql said:
mysql> LOAD DATA LOCAL INFILE 'c:/ZIP_CODES.txt'
-> INTO TABLE zip_code
-> FIELDS TERMINATED BY ',' ENCLOSED BY '"'
-> LINES TERMINATED BY '\r\n';
http://27.org/isocountrylist/usps_states_list.sql
SQL file for creating a states table (i believe in the zipcode class, he wants the states table called "state")
i used that to make a silly little app to test some of the features of the class:
<?php
$link = mysql_connect('server', 'user', 'pass')
or die('Could not connect: '.mysql_error());
mysql_select_db('zipcodes') or die('Could not connect to db.');
include 'classes/class.zipcode_class.php';
$zc = new zipcode_class;
$zips = array("0","0");
foreach($zips as $key => $zip){
$field = 'zip'.($key+1);
if(isset($_REQUEST[$field])){
if(is_numeric($_REQUEST[$field])){
$zips[$key] = $_REQUEST[$field];
}
}
}
?>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="GET">
<input type="text" name="zip1" value="<?=$zips[0];?>" /> <input type="text" name="zip2" value="<?=$zips[1];?>" /> <input type="submit" />
</form>
<?
foreach($zips as $key => $zip){
if($zip){
echo "<ul>";
echo "<strong>$zip:</strong>";
$details = $zc->get_zip_details($zip);
if(!empty($details)){
foreach($details as $key => $value){
echo "<li><strong>$key:</strong> $value</li>";
}
}
echo "</ul>";
}
}
?>
<br/>
<?
if($zips[0] && $zips[1]){
echo "Distance: ".$zc->get_distance($zips[0], $zips[1]);
}
?>oh, and i found this http://centricle.com/tools/html-entities/ to convert app code into HTML special chars
crossposted in
php
mysql &