I know, I know. Another PHP/MySQL article! I swore that my next article would be something completely different, but then my colleague emailed me some SQL for distance calculation, I plugged it into the PHP code from previous articles, and the result was just too cool and easy that I had to share it with you all.
The article goes over the usual - setting up the database (this one uses pizza restaurant data from all over the U.S.), querying the database with a SQL statement based on the Haversine formula, outputting the XML, and then hooking it up to a nice UI that performs a geocode based on a user-entered address, and then displays the n-nearest locations on a map within a user-selected radius. A screenshot of the final map is shown below:
To any chain stores out there that aren't using the Google Maps API yet (I know, perish the thought!) - the excuses are over, and the time has come to implement. And to people who don't have stores to locate - the time has come for you to become an entrepreneur and start-up your own chain of businesses. Here are some ideas of mine that would make for wicked cute map icons: a pizza buffet (all you can eat pizza, including dessert pizzas!), a boba bar (alcohol + caramelized tapioca pearls = yum!), or a "pamela's patented puffsters" diner (George Foreman grill + Bisquick pancake mix = half fluffy, half crispy, all delicious!). I expect 50% split of the profits, of course.
As always, please give feedback on this article in the forum.