SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2001
    New York
    0 Post(s)
    0 Thread(s)

    Help implementing Zip Code Radius

    I'm hoping someone can give me a little hand trying to apply a PHP script to do zip code radii into a directory script. I have an .inc file which is supposed to be all I need. It contains essentially only the following but I'm not sure how one would use this to say "find all zip codes within a radius of 5 miles."

    I assume you take the variable in from the zip code field you entered in the form, and then you apply radiuscalc function by plugging in the miles. The challenge I'm having is how do you use the other functions and have it return a set of all the records that correspond to the area? Does it creat a set where you have a low and high lat and all the cities that fall in between those and the low and high long are the set of cities within the radius? That seems logical but I'm not sure of the mysql queries.

    Is there a way to see what this looks like in action? Many thanks to anyone who can help. I'm trying to put this into an indexu database but any database/directory example will do.


    class radiuscalc {

    var $highlat;
    var $lowlat;
    var $higlong;
    var $lowlong;

    function radiuscalc ($lat, $long, $mi) {
    global $highlat,$lowlat,$highlong,$lowlong;
    $equator_mile = 69.2;
    $highlat = $Latitude + $Miles / $equator_mile;
    $minlat = $Latitude + $Miles / $equator_mile;
    $highlong = ......
    $lowlong= $long- ($highlong- $long);

    function highlat() {
    return $GLOBALS["highlat"];
    function lowlat() {.....}
    function highlong() {....}
    function lowlong() {
    return $GLOBALS["lowlong"];


    My law forum and legal information website -- I also buy websites you may wish to sell

  2. #2


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts