OK, I admit I am completely clueless on how to perform this one.
In one table I have a list zip codes and the user will select one or more from this list. Once I have those zip codes, I need to perform my query and this is where it gets rough.
In my users table I have a million records that have a geocoded latitude and longitude. What I need to do is return a list of "zones"
Let's say the user selects a zip of 33308. In 33308 I have 5,000 users. I need to break the 5,000 users down in to maybe a dozen zones of 'x' distance with 1 user being the center of that zone and any other users in that zone being ommited from the results.
Then the next row returned being a new zone with one user at the center and all other users in that zone being omitted. Wash, rinse, repeat until I have all the zones.
SELECT *,(((acos(sin((".[B]$lat[/B]."*pi()/180)) * sin((`lat`*pi()/180))+cos((".[B]$lat[/B]."*pi()/180)) * cos((`lat`*pi()/180))* cos(((".[B]$lon[/B]."- `lon`)*pi()/180))))*180/pi())*60*1.1515) AS dist_x FROM `message` HAVING dist_x<=".[B]$distance[/B]." AND dist_x<=[B]$distance[/B] ORDER BY dist_x ASC";
With the above query I have no problem querying ALL users within 'x' distance of a specific address, what I dont know how to do is only get one user and make that user the center of a "zone" and omit all other users from that "zone" and then get another zone. I prefer to do as much as this in mysql vs php for speed/performance reasons but I've no clue how to do this in php either! LOL
Suggestions?