<?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: How to Code a Simple Zip Code Locator in PHP</title>
	<atom:link href="http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/</link>
	<description>Web Development from the Front Lines</description>
	<lastBuildDate>Wed, 18 Aug 2010 14:46:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: James Ehly</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/comment-page-1/#comment-58352</link>
		<dc:creator>James Ehly</dc:creator>
		<pubDate>Fri, 05 Mar 2010 04:30:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-58352</guid>
		<description>You must have missed the note at the top:

&lt;blockquote&gt;
&lt;em&gt;This tutorial is now out of date since Yahoo has changed the map API. I’ll try to make a new tutorial using the new Yahoo AJAX API soon.&lt;/em&gt;&lt;/blockquote&gt;

The old API no longer works.  I still haven&#039;t gotten around to making a new one, so the best resource now is going to be the Yahoo Maps API pages.  There&#039;s lots of examples there on how the use the new mapping api.  Plus I found this great guide just the other day for google maps:

http://code.google.com/apis/maps/articles/phpsqlsearch.html</description>
		<content:encoded><![CDATA[<p>You must have missed the note at the top:</p>
<blockquote><p>
<em>This tutorial is now out of date since Yahoo has changed the map API. I’ll try to make a new tutorial using the new Yahoo AJAX API soon.</em></p></blockquote>
<p>The old API no longer works.  I still haven&#8217;t gotten around to making a new one, so the best resource now is going to be the Yahoo Maps API pages.  There&#8217;s lots of examples there on how the use the new mapping api.  Plus I found this great guide just the other day for google maps:</p>
<p><a href="http://code.google.com/apis/maps/articles/phpsqlsearch.html" rel="nofollow">http://code.google.com/apis/maps/articles/phpsqlsearch.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blech</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/comment-page-1/#comment-58349</link>
		<dc:creator>Blech</dc:creator>
		<pubDate>Fri, 05 Mar 2010 01:49:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-58349</guid>
		<description>I hate to rain on this as it is a nice start but I&#039;ve fought with this code for a deadline I have and unfortunately haven&#039;t been able to get it working after 3 hours of fiddling with different parts of this code... pretty frustrating.</description>
		<content:encoded><![CDATA[<p>I hate to rain on this as it is a nice start but I&#8217;ve fought with this code for a deadline I have and unfortunately haven&#8217;t been able to get it working after 3 hours of fiddling with different parts of this code&#8230; pretty frustrating.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/comment-page-1/#comment-57971</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Tue, 23 Jun 2009 14:45:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-57971</guid>
		<description>Thanks for putting this out here!

What do you do for pagination? I got it working (without Yahoo integration, as I don&#039;t need it) and implemented pagination. When I did that, the results were all messed up. I can&#039;t for the life of me figure out why. Do you have an example?</description>
		<content:encoded><![CDATA[<p>Thanks for putting this out here!</p>
<p>What do you do for pagination? I got it working (without Yahoo integration, as I don&#8217;t need it) and implemented pagination. When I did that, the results were all messed up. I can&#8217;t for the life of me figure out why. Do you have an example?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/comment-page-1/#comment-57969</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Sat, 20 Jun 2009 00:58:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-57969</guid>
		<description>How do you paginate this? I&#039;ve been trying every which way I can and every result is wrong. Once I remove my pagination the results are in the correct order again.</description>
		<content:encoded><![CDATA[<p>How do you paginate this? I&#8217;ve been trying every which way I can and every result is wrong. Once I remove my pagination the results are in the correct order again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shan</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/comment-page-1/#comment-57922</link>
		<dc:creator>Shan</dc:creator>
		<pubDate>Mon, 30 Mar 2009 16:17:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-57922</guid>
		<description>This is awesome... but the multiple part is not working for me...
after I insert the zip I get
The web developers closest to: 11501

&#039;You are here&#039;,&#039;11501&#039;,&#039;You are here&#039;,&#039;11501&#039;,&#039;&#039;,&#039; &#039;,&#039;&#039;,&#039; &#039;,&#039;&#039;,&#039; 
&#039;Array ( [id] =&gt; 2 [name] =&gt; test1 [address1] =&gt; 450 Hillside Ave [address2] =&gt; [city] =&gt; New Hyde Park [state] =&gt; New York [zip] =&gt; 11040 [phone1] =&gt; 5551212[website] =&gt; http://www.mmaxtra.com[pavailable] =&gt; no =&gt; Yes [kutbha_hr] =&gt; [kutbha_min] =&gt; [email] =&gt; info@mmaxtra.com ) 

So I get a blank map and still get one location? Would you happen to know what am I doing wrong?</description>
		<content:encoded><![CDATA[<p>This is awesome&#8230; but the multiple part is not working for me&#8230;<br />
after I insert the zip I get<br />
The web developers closest to: 11501</p>
<p>&#8216;You are here&#8217;,'11501&#8242;,&#8217;You are here&#8217;,'11501&#8242;,&#8221;,&#8217; &#8216;,&#8221;,&#8217; &#8216;,&#8221;,&#8217;<br />
&#8216;Array ( [id] =&gt; 2 [name] =&gt; test1 [address1] =&gt; 450 Hillside Ave [address2] =&gt; [city] =&gt; New Hyde Park [state] =&gt; New York [zip] =&gt; 11040 [phone1] =&gt; 5551212[website] =&gt; <a href="http://www.mmaxtra.compavailable" rel="nofollow">http://www.mmaxtra.compavailable</a> =&gt; no =&gt; Yes [kutbha_hr] =&gt; [kutbha_min] =&gt; [email] =&gt; <a href="mailto:info@mmaxtra.com">info@mmaxtra.com</a> ) </p>
<p>So I get a blank map and still get one location? Would you happen to know what am I doing wrong?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Ehly</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/comment-page-1/#comment-53708</link>
		<dc:creator>James Ehly</dc:creator>
		<pubDate>Thu, 01 May 2008 14:44:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-53708</guid>
		<description>A few people have asked me this, so here is the looping code you&#039;ll need.

Find this line and add some code like this...

&lt;code&gt;// now we can display closest store
// optionally you could loop over this to list multiple stores
$store = $storeinfo[key($stores)];
print &quot;&lt;p&gt;The web developers closest to: $findzip&lt;/p&gt;&lt;br&gt;\n&quot;;
$maploc = &quot;&#039;You are here&#039;,&#039;$findzip&#039;,&quot;;
foreach($stores as $k=&gt;$v) {
  $output .= &quot;&lt;h3 style=&#039;margin:0;padding:0&#039;&gt;&lt;b&gt;&quot;.$info[$k][&#039;company&#039;].&quot;&lt;/b&gt;&lt;br&gt;(approx &quot;.round($v).&quot; miles)&lt;/h3&gt;&quot;;
  $output .= &quot;&lt;p style=&#039;margin:0 0 10px 0;padding:0&#039;&gt;&lt;a href=&#039;&quot;.$info[$k][&#039;url&#039;].&quot;&#039;&gt;&quot;.$info[$k][&#039;url&#039;].&quot;&lt;/a&gt;&lt;br&gt;&quot;;
  $output .= $info[$k][&#039;city&#039;].&quot; &quot;.$info[$k][&#039;state&#039;].&quot;, &quot;.$info[$k][&#039;zip&#039;].&quot;&lt;/p&gt;&quot;;
  $maploc .= &quot;&#039;&quot;.$info[$k][&#039;company&#039;].&quot;&#039;,&#039;&quot;.$info[$k][&#039;address1&#039;].&quot; &quot;.$info[$k][&#039;city&#039;].&quot; &quot;.$info[$k][&#039;state&#039;].&quot; &quot;.$info[$k][&#039;zip&#039;].&quot;&#039;,&quot;;
}
$maploc = substr($maploc,0,-1);&lt;/code&gt;

And here are the changes to the javascript:

&lt;code&gt;&lt;script&gt;
// this is the address we want to map (you can list several and it will mark each one)
var addresses = new Array(&lt;?=$maploc?&gt;);
// Create and display Map object at the address with zoom level 3
// Include your application ID.
var map = new Map(&quot;mapContainer&quot;, &quot;[your api key here]&quot;, &quot;&lt;?=$maploc?&gt;&quot;,20);
map.addEventListener(Map.EVENT_INITIALIZE, onMapInit);
map.addEventListener(Map.EVENT_MARKER_GEOCODE_SUCCESS,onMarkerGeocode);
function onMapInit(eventObj) {
map.addTool( new PanTool(), true );
for(var i=0; i&lt;addresses.length; i=i+2) {
//alert(addresses[i]);
//alert(addresses[i+1]);
// if you did do multiple addresses, then this would have to change some (because it would be the same store each iteration)
var marker = new CustomPOIMarker(addresses[i], &#039;&#039;, addresses[i+1], &#039;0x000000&#039;, &#039;0xFFFFFF&#039;);
map.addMarkerByAddress( marker, addresses[i+1] );
}
map.addWidget( new ZoomBarWidget() );
}
function onMarkerGeocode(eventObj) {
var geocodeResponse = eventObj.response;
}
&lt;/script&gt;&lt;/code&gt;

Basically what you are doing is building an array of results and looping over then with the javascript.

Hope this helps.  James</description>
		<content:encoded><![CDATA[<p>A few people have asked me this, so here is the looping code you&#8217;ll need.</p>
<p>Find this line and add some code like this&#8230;</p>
<p><code>// now we can display closest store<br />
// optionally you could loop over this to list multiple stores<br />
$store = $storeinfo[key($stores)];<br />
print &quot;&lt;p&gt;The web developers closest to: $findzip&lt;/p&gt;&lt;br&gt;\n&quot;;<br />
$maploc = &quot;'You are here','$findzip',&quot;;<br />
foreach($stores as $k=&gt;$v) {<br />
  $output .= &quot;&lt;h3 style='margin:0;padding:0'&gt;&lt;b&gt;&quot;.$info[$k]['company'].&quot;&lt;/b&gt;&lt;br&gt;(approx &quot;.round($v).&quot; miles)&lt;/h3&gt;&quot;;<br />
  $output .= &quot;&lt;p style='margin:0 0 10px 0;padding:0'&gt;&lt;a href='&quot;.$info[$k]['url'].&quot;'&gt;&quot;.$info[$k]['url'].&quot;&lt;/a&gt;&lt;br&gt;&quot;;<br />
  $output .= $info[$k]['city'].&quot; &quot;.$info[$k]['state'].&quot;, &quot;.$info[$k]['zip'].&quot;&lt;/p&gt;&quot;;<br />
  $maploc .= &quot;'&quot;.$info[$k]['company'].&quot;','&quot;.$info[$k]['address1'].&quot; &quot;.$info[$k]['city'].&quot; &quot;.$info[$k]['state'].&quot; &quot;.$info[$k]['zip'].&quot;',&quot;;<br />
}<br />
$maploc = substr($maploc,0,-1);</code></p>
<p>And here are the changes to the javascript:</p>
<p><code>&lt;script&gt;<br />
// this is the address we want to map (you can list several and it will mark each one)<br />
var addresses = new Array(&lt;?=$maploc?&gt;);<br />
// Create and display Map object at the address with zoom level 3<br />
// Include your application ID.<br />
var map = new Map(&quot;mapContainer&quot;, &quot;[your api key here]&quot;, &quot;&lt;?=$maploc?&gt;&quot;,20);<br />
map.addEventListener(Map.EVENT_INITIALIZE, onMapInit);<br />
map.addEventListener(Map.EVENT_MARKER_GEOCODE_SUCCESS,onMarkerGeocode);<br />
function onMapInit(eventObj) {<br />
map.addTool( new PanTool(), true );<br />
for(var i=0; i&lt;addresses.length; i=i+2) {<br />
//alert(addresses[i]);<br />
//alert(addresses[i+1]);<br />
// if you did do multiple addresses, then this would have to change some (because it would be the same store each iteration)<br />
var marker = new CustomPOIMarker(addresses[i], '', addresses[i+1], '0x000000', '0xFFFFFF');<br />
map.addMarkerByAddress( marker, addresses[i+1] );<br />
}<br />
map.addWidget( new ZoomBarWidget() );<br />
}<br />
function onMarkerGeocode(eventObj) {<br />
var geocodeResponse = eventObj.response;<br />
}<br />
&lt;/script&gt;</code></p>
<p>Basically what you are doing is building an array of results and looping over then with the javascript.</p>
<p>Hope this helps.  James</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: josh</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/comment-page-1/#comment-53707</link>
		<dc:creator>josh</dc:creator>
		<pubDate>Thu, 01 May 2008 14:17:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-53707</guid>
		<description>What do i have to do to show more stores?</description>
		<content:encoded><![CDATA[<p>What do i have to do to show more stores?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Internet Television</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/comment-page-1/#comment-30115</link>
		<dc:creator>Internet Television</dc:creator>
		<pubDate>Thu, 24 Jan 2008 22:16:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-30115</guid>
		<description>That&#039;s absolutely beautiful, great work.</description>
		<content:encoded><![CDATA[<p>That&#8217;s absolutely beautiful, great work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: October 2007 Recap and Traffic Report &#124; DEVTRENCH: Web Development from the Front Lines</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/comment-page-1/#comment-11360</link>
		<dc:creator>October 2007 Recap and Traffic Report &#124; DEVTRENCH: Web Development from the Front Lines</dc:creator>
		<pubDate>Fri, 02 Nov 2007 13:57:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-11360</guid>
		<description>[...] spam and web stats: Usi...How to Code a Simple Zip Code Loc...WPA Can also be Cracked!!...Out sick: Preparing for a regular...Getting Technorati Authority [...]</description>
		<content:encoded><![CDATA[<p>[...] spam and web stats: Usi&#8230;How to Code a Simple Zip Code Loc&#8230;WPA Can also be Cracked!!&#8230;Out sick: Preparing for a regular&#8230;Getting Technorati Authority [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Ehly</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/comment-page-1/#comment-9652</link>
		<dc:creator>James Ehly</dc:creator>
		<pubDate>Mon, 22 Oct 2007 15:42:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-9652</guid>
		<description>Well I just figured out a logical error in the script. If you find by state first then that might not actually be the closest location to you (since there might be a closer location in the state next to you).  Just comment out the lines about querying the state first and you should be fine.  However, I assume doing this will slow the code down quite a bit if you have a ton of locations to search against.  Maybe caching the queries somehow would be in order.

James</description>
		<content:encoded><![CDATA[<p>Well I just figured out a logical error in the script. If you find by state first then that might not actually be the closest location to you (since there might be a closer location in the state next to you).  Just comment out the lines about querying the state first and you should be fine.  However, I assume doing this will slow the code down quite a bit if you have a ton of locations to search against.  Maybe caching the queries somehow would be in order.</p>
<p>James</p>
]]></content:encoded>
	</item>
</channel>
</rss>
