473,413 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Search by zip code

Does anyone know if there are any modules available that enable searches by
zipcode for proximity? I want the user to enter a zipcode and then I want
to somehow search for all entries in a database that are within, say, 25
miles of that zipcode. This is done in many, many sites on the net and I am
wondering if anyone knows of an add-on package to make it happen. No sense
in re-inventing the wheel.

Shelly
Jul 17 '05 #1
5 2073
Shelly wrote:
Does anyone know if there are any modules available that enable searches by
zipcode for proximity? I want the user to enter a zipcode and then I want
to somehow search for all entries in a database that are within, say, 25
miles of that zipcode. This is done in many, many sites on the net and I am
wondering if anyone knows of an add-on package to make it happen. No sense
in re-inventing the wheel.

Shelly


Shelly,

I don't have the code handy - but it's not hard to develop.

Basically store zip codes, longitude and latitude in a database (i.e. MySQL).

Take the long/lat of the entered zipcode. Create minimum and maximum long/lat
for your desired radius (a little searching of the internet will give you the
equations). Then search for any zip code with long/lat within the given range.

Finally, for fine tuning, check the distance of the returned zip code against
the entered zip code (similar formulae).

Last time I did it it was all of about six lines of code and ram in < 1 sec.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #2
I use this one for perl and call it by shell_exec() in my php script :

http://www.cryptnet.net/fsp/zipdy/

I am sure there must be an all php solution, but this works fine for
what I needed.

Jul 17 '05 #3
Hello,

Shelly wrote:
Does anyone know if there are any modules available that enable searches by
zipcode for proximity? I want the user to enter a zipcode and then I want
to somehow search for all entries in a database that are within, say, 25
miles of that zipcode. This is done in many, many sites on the net and I am
wondering if anyone knows of an add-on package to make it happen. No sense
in re-inventing the wheel.


Sure, try either of these packages:

Class: php Zip Locator
http://www.phpclasses.org/phpziplocator

Class: Zip Codes Range
http://www.phpclasses.org/zipcodesrange

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #4

"Manuel Lemos" <ml****@acm.org> wrote in message
news:da**********@domitilla.aioe.org...
Hello,

Shelly wrote:
Does anyone know if there are any modules available that enable searches
by zipcode for proximity? I want the user to enter a zipcode and then I
want to somehow search for all entries in a database that are within,
say, 25 miles of that zipcode. This is done in many, many sites on the
net and I am wondering if anyone knows of an add-on package to make it
happen. No sense in re-inventing the wheel.


Sure, try either of these packages:

Class: php Zip Locator
http://www.phpclasses.org/phpziplocator

Class: Zip Codes Range
http://www.phpclasses.org/zipcodesrange

--

Regards,
Manuel Lemos


Thank you. I recently subscribed to PHPclasses. The
http://www.phpclasses.org/zipcodesrange
looks like exactly what I need. I do need a little education, however. So,
if you could either point me to the proper place or explain it to me, I
would be appreciative.

1 - That class has a require of DB.php. There was none in the download.
Where can I find that one.

2 - It has the the syntax "$db =& DB::connect(DSN);" . What is the
"::"? What is the "DB"?

3 - DSN was defined as "define ('DSN', 'pgsql://user@localhost/database');".
Can you explain the second argument? It look like a URL.

4 - In using this class, do I simply create a variable with something like:
$my_var = new ZipCodesRange(<the arguments>);
and then access the zipcodes that satisfy as:
$my_var->zipcodes[$i] ?

5 - Can the zipcode table simply be a table in my main database?

These may seem like obvious questions to you, but it is questions like these
that have blocked my using the PHPclasses stuff. It seem like an
exceptionally rich collection of material.

Thanks,
Shelly
Jul 17 '05 #5
Shelly wrote:
1 - That class has a require of DB.php. There was none in the download.
Where can I find that one.
pear.php.net
2 - It has the the syntax "$db =& DB::connect(DSN);" . What is the
"::"? What is the "DB"?

3 - DSN was defined as "define ('DSN', 'pgsql://user@localhost/database');".
Can you explain the second argument? It look like a URL.
Its an URI, not URL. PEAR::DB can take an argument as either a hash,
or a URI. It means "connect to a postgresql db as "user", on machine
"localhost", and access database called "database".

4 - In using this class, do I simply create a variable with something like:
$my_var = new ZipCodesRange(<the arguments>);
and then access the zipcodes that satisfy as:
$my_var->zipcodes[$i] ?
"new" will create a new instance from class ZipCodeRange
5 - Can the zipcode table simply be a table in my main database?


Sure. You can store just about any kind of information in a db ;-)
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Anand Pillai | last post by:
To search a word in a group of words, say a paragraph or a web page, would a string search or a regexp search be faster? The string search would of course be, if str.find(substr) != -1:...
1
by: Les Juby | last post by:
A year or two back I needed a search script to scan thru HTML files on a client site. Usual sorta thing. A quick search turned up a neat script that provided great search results. It was fast,...
8
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled...
5
by: pembed2003 | last post by:
Hi all, I need to write a function to search and replace part of a char* passed in to the function. I came up with the following: char* search_and_replace(char* source,char search,char*...
28
by: joshc | last post by:
If I have an array of data that I know to be sorted in increasing order, and the array is less than 50 elements, and I want to find the first element greater than a certain value, is a simple...
8
by: Huihong | last post by:
Please check out our newly released source code search engine here, http://www.codase.com e.g., search socket method call,...
1
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
9
by: weirdguy | last post by:
Hello, Just for anyone information, there is a similar title "Search in Listbox" but it is via Combo Box. In case, anyone need it, I put a link to here. Please let me know if I break any rules...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
5
by: nicehulk | last post by:
I'm doing a library for DVD-movies and I'm trying to figure out how to search different categories like director, title, actor etc. (which are all variables in a DVD-class). Previously I did like...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.