The search conditions are:
Business Name:
Zip:
With in(Miles)
Suppose i have given a business name say computer.
Zip code : 35034
and with in 20 miles
The result should show the business names whose distans lies with in 20 miles of the area whose zip is 35034.
Pls give me suggestion for that.
Search Results by Zip Code distance wise
Moderator: General Moderators
Code: Select all
$query_search="SELECT bus_name FROM tbl_name WHERE dis <=20 AND zip=35034";- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
This will not work. In order to make the distance work properly you need to calculate the arc distance (as feyd stated, the great circle radius) then use that as your distance.kpraman wrote:Code: Select all
$query_search="SELECT bus_name FROM tbl_name WHERE dis <=20 AND zip=35034";
This is a somewhat involved process and can be very resource intensive.
There are lots of examples of ways to calculate this. It's not very processor friendly as it involves heavy DB queries across thousands of rows.
I can't vouch for this resource, but it looks like a good starting point.
http://www.micahcarrick.com/v2/content/view/4/3/
I can't vouch for this resource, but it looks like a good starting point.
http://www.micahcarrick.com/v2/content/view/4/3/
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
-
MicahCarrick
- Forum Newbie
- Posts: 23
- Joined: Sat Apr 09, 2005 5:40 pm
My script has been updated (the database) by end user contributions. It's now available at http://www.micahcarrick.com/04-19-2005/php-zip-code-range-and-distance-calculation.html
A user, Jeff Bearer, submitted a fix which reduced the db load a bit and made the code MUCH faster.
Personally, I haven't worked with this script in 2 years, however, I try to address user emails and comments as they come to me and update the code.
By the way, if y'all find other scripts and/or databases which are free that work well, I'd love to know. I'll link to them from my site.
A user, Jeff Bearer, submitted a fix which reduced the db load a bit and made the code MUCH faster.
Personally, I haven't worked with this script in 2 years, however, I try to address user emails and comments as they come to me and update the code.
By the way, if y'all find other scripts and/or databases which are free that work well, I'd love to know. I'll link to them from my site.