'; //Use lat and long passed from google map to find US state $sql = '(SIN(RADIANS('.$lat.')) * SIN(RADIANS(`LATITUDE`)) + COS(RADIANS('.$lat.')) * COS(RADIANS(`LATITUDE`)) * COS(RADIANS((('.$long.') - (`LONGITUDE`)))))'; $sql = 'ACOS'.$sql; $sql = 'DEGREES('.$sql.')'; $sql = '('.$sql.' * 60 * 1.1515)'; //copy current sql to $whereMiles $sql = 'select STATE from zipcodes where ( '.$sql.' <= 50) limit 1'; $results = mysql_query($sql,$conn) or die(mysql_error()); //IF State was found if(mysql_num_rows($results) > 0){ $state = mysql_fetch_assoc($results); //Fetch all counties $counties_sql = 'SELECT * FROM zipcodes WHERE STATE = "'.$state['STATE'].'" GROUP BY COUNTY ORDER BY `COUNTY` DESC '; $countiesR = mysql_query($counties_sql,$conn) or die(mysql_error()); //Output County Xml while($county = mysql_fetch_assoc($countiesR)){ $xmlNode = ' 0){ //Output County Xml while($property = mysql_fetch_assoc($results)){ $xmlNode = '
Bath(s): '.$property['bath'].'
Price: '.$property['price'].'
View Details
]]>'; $xmlNode .= '
'; $xmlOUTPUT[] = $xmlNode; } } $xmlOUTPUT[] = ''; //Print XML OUTPUT foreach($xmlOUTPUT as $elements) print $elements . "\r\n"; } //findState(33.7243396617476,-81.03515625,$myconn); ?>