<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Getting All ZIP Codes In A Given Radius From A Known Point / ZIP Code Via PHP And MySQL</title>
	<atom:link href="http://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/</link>
	<description>ASP.NET, PHP, XML, JavaScript, Web geekery, Entrepreneurship</description>
	<lastBuildDate>Fri, 18 May 2012 10:23:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/#comment-235</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Thu, 27 Jan 2011 15:48:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1776#comment-235</guid>
		<description>@Rick: Change the SQL statement to not exclude the initial ZIP Code.

This:
[php firstline=&quot;46&quot;]$query = &quot;SELECT * FROM php_zip_code_distance WHERE (latitude &lt;= $latN AND latitude &gt;= $latS AND longitude &lt;= $lonE AND longitude &gt;= $lonW) AND (latitude != $lat1 AND longitude != $lon1) AND city != &#039;&#039; ORDER BY state, city, latitude, longitude&quot;;[/php]

Becomes this:
[php firstline=&quot;46&quot;]$query = &quot;SELECT * FROM php_zip_code_distance WHERE (latitude &lt;= $latN AND latitude &gt;= $latS AND longitude &lt;= $lonE AND longitude &gt;= $lonW) AND city != &#039;&#039; ORDER BY state, city, latitude, longitude&quot;;[/php]</description>
		<content:encoded><![CDATA[<p>@Rick: Change the SQL statement to not exclude the initial ZIP Code.</p>
<p>This:</p>
<pre class="brush: php; first-line: 46; title: ; notranslate">$query = &quot;SELECT * FROM php_zip_code_distance WHERE (latitude &lt;= $latN AND latitude &gt;= $latS AND longitude &lt;= $lonE AND longitude &gt;= $lonW) AND (latitude != $lat1 AND longitude != $lon1) AND city != '' ORDER BY state, city, latitude, longitude&quot;;</pre>
<p>Becomes this:</p>
<pre class="brush: php; first-line: 46; title: ; notranslate">$query = &quot;SELECT * FROM php_zip_code_distance WHERE (latitude &lt;= $latN AND latitude &gt;= $latS AND longitude &lt;= $lonE AND longitude &gt;= $lonW) AND city != '' ORDER BY state, city, latitude, longitude&quot;;</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick</title>
		<link>https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/#comment-234</link>
		<dc:creator>Rick</dc:creator>
		<pubDate>Thu, 27 Jan 2011 13:00:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1776#comment-234</guid>
		<description>I found your script and I have integrated your plus the ability to find &quot;stores&quot; based on the list of initially found zip codes.  Work well, your script was really nice.   SO instead of displaying a list of zip codes it now display a list of &quot;places&quot; found within my database with those zip.

While testing yesterday  I found an interesting issue with your base code.  When searching for a radius of zips, it does not return the zip of the initially search zip and perhaps more.  So I went back to your demo and it exhibits the same issue.  Since I am in Connecticut, I tried to use a zip code 06896 and it find the zip, then display all the zips except for those in Redding, (the zip code I used)  Actually there are 4 zipcodes tied to Redding so I&#039;m guessing that the searched zip code and any other the same town are not being returned.  It is not just this zip code that manifests the issue.  Try 10010 a NYC zip.

I&#039;ll need to figure out what your zip list routine is doing and adjust it.
thanks</description>
		<content:encoded><![CDATA[<p>I found your script and I have integrated your plus the ability to find &#8220;stores&#8221; based on the list of initially found zip codes.  Work well, your script was really nice.   SO instead of displaying a list of zip codes it now display a list of &#8220;places&#8221; found within my database with those zip.</p>
<p>While testing yesterday  I found an interesting issue with your base code.  When searching for a radius of zips, it does not return the zip of the initially search zip and perhaps more.  So I went back to your demo and it exhibits the same issue.  Since I am in Connecticut, I tried to use a zip code 06896 and it find the zip, then display all the zips except for those in Redding, (the zip code I used)  Actually there are 4 zipcodes tied to Redding so I&#8217;m guessing that the searched zip code and any other the same town are not being returned.  It is not just this zip code that manifests the issue.  Try 10010 a NYC zip.</p>
<p>I&#8217;ll need to figure out what your zip list routine is doing and adjust it.<br />
thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rick</title>
		<link>https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/#comment-233</link>
		<dc:creator>rick</dc:creator>
		<pubDate>Thu, 10 Jun 2010 15:08:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1776#comment-233</guid>
		<description>Field names I figured out. Field types (numeric, float, text, length, etc) are not so obvious.

For instance, the &#039;radius search&#039; program requires numeric fields of some sort for lat/long, but the two-level state/city article doesn&#039;t need numeric lat/long. And I&#039;m having difficulty with the import of the zip.csv file into the lat/long fields.

So the field types/lengths is important information, IMHO.

Thanks...Rick...</description>
		<content:encoded><![CDATA[<p>Field names I figured out. Field types (numeric, float, text, length, etc) are not so obvious.</p>
<p>For instance, the &#8216;radius search&#8217; program requires numeric fields of some sort for lat/long, but the two-level state/city article doesn&#8217;t need numeric lat/long. And I&#8217;m having difficulty with the import of the zip.csv file into the lat/long fields.</p>
<p>So the field types/lengths is important information, IMHO.</p>
<p>Thanks&#8230;Rick&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/#comment-232</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Thu, 10 Jun 2010 12:11:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1776#comment-232</guid>
		<description>@rick: It&#039;s self-explanatory from the code: columns for ZIP Code, latitude, longitude, city and state. Oh, and a primary key, or course.</description>
		<content:encoded><![CDATA[<p>@rick: It&#8217;s self-explanatory from the code: columns for ZIP Code, latitude, longitude, city and state. Oh, and a primary key, or course.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rick</title>
		<link>https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/#comment-231</link>
		<dc:creator>rick</dc:creator>
		<pubDate>Thu, 10 Jun 2010 04:09:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1776#comment-231</guid>
		<description>Great article (and the one on two-level state/city lookup).

Might I suggest that, since you are not providing the zip code database in your download, that you describe the structure of the zipcode table.

Thanks...Rick...</description>
		<content:encoded><![CDATA[<p>Great article (and the one on two-level state/city lookup).</p>
<p>Might I suggest that, since you are not providing the zip code database in your download, that you describe the structure of the zipcode table.</p>
<p>Thanks&#8230;Rick&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/#comment-230</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Wed, 12 Aug 2009 17:06:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1776#comment-230</guid>
		<description>@neel: When I imported the ZIP code database, I mistakenly set the size and precision of the longitude column in my MySQL database to (8,6). Therefore, any values -100 and below were automatically converted to -99.999999. (Hey, I&#039;m from New England. Sometimes I forget that things exist west of the Ohio River.)

I have corrected the size of the latitude and longitude columns, re-imported the data and the demo should now be returning proper values. Apologies and thanks for catching my error.</description>
		<content:encoded><![CDATA[<p>@neel: When I imported the ZIP code database, I mistakenly set the size and precision of the longitude column in my MySQL database to (8,6). Therefore, any values -100 and below were automatically converted to -99.999999. (Hey, I&#8217;m from New England. Sometimes I forget that things exist west of the Ohio River.)</p>
<p>I have corrected the size of the latitude and longitude columns, re-imported the data and the demo should now be returning proper values. Apologies and thanks for catching my error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: neel</title>
		<link>https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/#comment-229</link>
		<dc:creator>neel</dc:creator>
		<pubDate>Wed, 12 Aug 2009 13:56:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1776#comment-229</guid>
		<description>Hi,
I tried the demo at mentioned link:
http://www.dougv.com/demo/php_zip_code_distance/

Entered zip code 94087 (sunnyvale,ca)  ( 37°22?7.56?N 122°2?13.4?W? / ?37.3687667°N 122.037056°W? / 37.3687667; -122.037056.)

But it is returning incorrect result. Does Db incorrectly contain sunnyvale long as -99.99 or it is script issue.
Thanks,
Neel

=============
Sunnyvale California 37.350091 -99.999999 37.711898145195 36.988283854805 -99.542662827632 -100.45733517237

City State ZIP Code Latitude Longitude Miles, Point A To B
Ashland Kansas 67831 37.196075 -99.776620 16.251589044657
Bloom Kansas 67865 37.394383 -99.967230 3.550269445576
Bucklin Kansas 67834 37.523175 -99.634350 23.355813537495
Englewood Kansas 67840 37.040749 -99.989030 21.383310186967
Ford Kansas 67842 37.549041 -99.748690 19.468577369373
==============================</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I tried the demo at mentioned link:<br />
<a href="http://www.dougv.com/demo/php_zip_code_distance/" rel="nofollow">http://www.dougv.com/demo/php_zip_code_distance/</a></p>
<p>Entered zip code 94087 (sunnyvale,ca)  ( 37°22?7.56?N 122°2?13.4?W? / ?37.3687667°N 122.037056°W? / 37.3687667; -122.037056.)</p>
<p>But it is returning incorrect result. Does Db incorrectly contain sunnyvale long as -99.99 or it is script issue.<br />
Thanks,<br />
Neel</p>
<p>=============<br />
Sunnyvale California 37.350091 -99.999999 37.711898145195 36.988283854805 -99.542662827632 -100.45733517237</p>
<p>City State ZIP Code Latitude Longitude Miles, Point A To B<br />
Ashland Kansas 67831 37.196075 -99.776620 16.251589044657<br />
Bloom Kansas 67865 37.394383 -99.967230 3.550269445576<br />
Bucklin Kansas 67834 37.523175 -99.634350 23.355813537495<br />
Englewood Kansas 67840 37.040749 -99.989030 21.383310186967<br />
Ford Kansas 67842 37.549041 -99.748690 19.468577369373<br />
==============================</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/#comment-228</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Fri, 17 Jul 2009 17:39:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1776#comment-228</guid>
		<description>Johnathan: No obligation, but I do appreciate anything you might send. As a rule, I&#039;ll do a follow-up or two for free.</description>
		<content:encoded><![CDATA[<p>Johnathan: No obligation, but I do appreciate anything you might send. As a rule, I&#8217;ll do a follow-up or two for free.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johnathan</title>
		<link>https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/#comment-227</link>
		<dc:creator>Johnathan</dc:creator>
		<pubDate>Fri, 17 Jul 2009 13:16:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1776#comment-227</guid>
		<description>Doug,

I was actually thinking on purchasing something since you have been very helpful.

I will try to work it out, but I may need more assistance in doing that.

Thank you and God bless,
Johnathan</description>
		<content:encoded><![CDATA[<p>Doug,</p>
<p>I was actually thinking on purchasing something since you have been very helpful.</p>
<p>I will try to work it out, but I may need more assistance in doing that.</p>
<p>Thank you and God bless,<br />
Johnathan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/#comment-226</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Fri, 17 Jul 2009 13:11:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1776#comment-226</guid>
		<description>Johnathan: There are two ways of accomplishing what you want. One would be to calculate the distance in the query itself, then use that as a sorting variable. This approach is propably the most elegant. However, you may find a small MySQL performance hit.

Another would be to query, put the records returned into a two-dimensional array, calculating the distance as you do so and adding it as a cell of the array. Then, you sort your array on the distance and output records that way. The benefit of this approach is that, if you don&#039;t know much about MySQL or are seeing performance problems in MySQL, it&#039;s a bit easier for most Web servers and new programmers to handle.

Best of luck with your project. If you&#039;d like any further assistance, I&#039;d ask that you purchase something from my Amazon wish list, which is linked under Copyright, Attribution and Donations.</description>
		<content:encoded><![CDATA[<p>Johnathan: There are two ways of accomplishing what you want. One would be to calculate the distance in the query itself, then use that as a sorting variable. This approach is propably the most elegant. However, you may find a small MySQL performance hit.</p>
<p>Another would be to query, put the records returned into a two-dimensional array, calculating the distance as you do so and adding it as a cell of the array. Then, you sort your array on the distance and output records that way. The benefit of this approach is that, if you don&#8217;t know much about MySQL or are seeing performance problems in MySQL, it&#8217;s a bit easier for most Web servers and new programmers to handle.</p>
<p>Best of luck with your project. If you&#8217;d like any further assistance, I&#8217;d ask that you purchase something from my Amazon wish list, which is linked under Copyright, Attribution and Donations.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

