rotwyla98 Posted November 18, 2006 Share Posted November 18, 2006 [move]PHP CODE[/move]I have code[code=php:0]function inradius($zip,$radius) { global $db; $query="SELECT * FROM zipData WHERE zipcode='$zip'"; $db->query($query); if($db->affected_rows()<>0) { $db->next_record(); $lat=$db->f("lat"); $lon=$db->f("lon"); $query="SELECT zipcode FROM zipData WHERE (POW((69.1*(lon-\"$lon\")*cos($lat/57.3)),\"2\")+POW((69.1*(lat-\"$lat\")),\"2\"))<($radius*$radius) "; $db->query($query); if($db->affected_rows()<>0) { while($db->next_record()) { $zipArray[$i]=$db->f("zipcode"); $i++; } } }else{ return "Zip Code not found"; } return $zipArray;[/code]where f is[code=php:0] function f($Name) { return $this->Record[$Name]; }[/code]I need for $zipArray[$i]=$db->f("zipcode"); to add another field.So...$zipArray[$i]=$db->f("zipcode"); <== puts 12345 into arrayI have another funtion which stores distance. To call this function:[code=php:0]$distance = $zipLoc->distance($zipOne,$zipTwo);[/code]I want to add $distance in line with the zipcode, so that when I print out the array, I can sort by distance. Quote Link to comment https://forums.phpfreaks.com/topic/27689-array-help/ Share on other sites More sharing options...
printf Posted November 18, 2006 Share Posted November 18, 2006 Why not just do it in query?show me a few lines of your database and I will show you how to do the radius and sort by the miles and return the miles as decimal (00.00)example... (what I want to see)[code]INSERT INTO `us` VALUES (1, 'NY', '1', 'New York', 'Holtsville', 00501, 'N', 40.813061, 'W', -73.046371, 'Suffolk', 'C', '631', 'Eastern', 1, -5, 17006);INSERT INTO `us` VALUES (2, 'NY', '1', 'New York', 'Holtsville', 00544, 'N', 40.813236, 'W', -73.049240, 'Suffolk', 'C', '631', 'Eastern', 1, -5, 17006);[/code]printf Quote Link to comment https://forums.phpfreaks.com/topic/27689-array-help/#findComment-126646 Share on other sites More sharing options...
rotwyla98 Posted November 18, 2006 Author Share Posted November 18, 2006 My database is very very simple... I can't find a free script which provides all of the above =/zipcode longitude latitude00210 71.0132 43.0058900211 71.0132 43.0058900212 71.0132 43.00589 Quote Link to comment https://forums.phpfreaks.com/topic/27689-array-help/#findComment-126671 Share on other sites More sharing options...
printf Posted November 18, 2006 Share Posted November 18, 2006 If you want a copy of mine, I just updated it on Nov 10, just PM me and I will give you a CSV file or if you want a SQL dump, I'll give you that. This my data set, it very accurate compared to all the very bad pay for ones, the only pretty good pay for data set comes from GreatData.Com, but even theirs has many errors (relating to proper naming) in both the US and Canadian data sets...If you want my set I'll give you an example using it, you can do both (driving and flying) miles, if not I will give you a simple example for your data!printf Quote Link to comment https://forums.phpfreaks.com/topic/27689-array-help/#findComment-126681 Share on other sites More sharing options...
rotwyla98 Posted November 18, 2006 Author Share Posted November 18, 2006 Cant send PM's yet =/Perhaps you can PM me your AIM/MSN sn or email and I'll send you my email.Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/27689-array-help/#findComment-126683 Share on other sites More sharing options...
printf Posted November 18, 2006 Share Posted November 18, 2006 Ok, just email me...fataqui@gmail.comHere is few examples that you can do with my dataset, I'll give you these scripts too!// distance from 1 zip to anotherhttp://zip.ya-right.com/distance/zip.php// radius by zip code or cityhttp://zip.ya-right.com/distance/radius.php// find the nearest post office from a given addresshttp://zip.ya-right.com/post/Sonia Quote Link to comment https://forums.phpfreaks.com/topic/27689-array-help/#findComment-126686 Share on other sites More sharing options...
rotwyla98 Posted November 18, 2006 Author Share Posted November 18, 2006 I checked out those links and they are exactly what i need (especially the post office one)I sent you an email.. waiting for response. Quote Link to comment https://forums.phpfreaks.com/topic/27689-array-help/#findComment-126712 Share on other sites More sharing options...
rotwyla98 Posted November 19, 2006 Author Share Posted November 19, 2006 =/ Patiently awaiting response.... Postponing fixing my current script to wait for yours. Quote Link to comment https://forums.phpfreaks.com/topic/27689-array-help/#findComment-127071 Share on other sites More sharing options...
rotwyla98 Posted November 21, 2006 Author Share Posted November 21, 2006 I guess she/he changed their mind.. anyone got any advice for my original code? Quote Link to comment https://forums.phpfreaks.com/topic/27689-array-help/#findComment-128143 Share on other sites More sharing options...
printf Posted November 21, 2006 Share Posted November 21, 2006 I didn't forget you, I'll most likely will send you the data and scripts tomorrow. I just have not had much time to add comments throughout the code, I got most of it done, I just need to comment a zip class and the db class and I will send it to you. I wasn't planning on giving it out so I never commented it, now I have, so you will have it tomorrow...printf Quote Link to comment https://forums.phpfreaks.com/topic/27689-array-help/#findComment-128172 Share on other sites More sharing options...
rotwyla98 Posted November 22, 2006 Author Share Posted November 22, 2006 Great! You can email me at rotwyla98[at]gmail[dot]com when you are ready.. I apparently tried to send a bunch of PMs but when I check my outbox, its empty =/ Quote Link to comment https://forums.phpfreaks.com/topic/27689-array-help/#findComment-128703 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.