Radius Search Results function in php -


i have search function on site takes city state , zip , searches radius , displays results found have tested breaks @ line of coding:

if ($origin_id[0] != -1)         $sql .= " , " . $prefix . ".originlocationid in (" . implode(",", $origin_id) . ") "; 

the globals defined , display correctly... if not put in radius display results city.. radius inputted breaks...

i have included radius function well...

function getlocationsearchcriteria(&$sql, &$urlappend, $prefix)     {         $origin_id = location::getlocationid($globals["originstate"], $globals["origincity"], $globals["originzip"]);          if (!is_array($origin_id))         {             $o = $origin_id;             $origin_id = array();             $origin_id[0] = $o;         }          if (!empty($globals["originradius"]))         {             $origin = new location($origin_id[0]); ----------->>>>>>   $origin_id = $origin->getradiuslocations($globals["originradius"]);             $urlappend .= "&originradius=" . $globals["originradius"];         }          // build query         if ($origin_id[0] != -1)             $sql .= " , " . $prefix . ".originlocationid in (" . implode(",", $origin_id) . ") ";     }      function getradiuslocations($radius)         {             $sql = "select locationid                      locations                      (pow((69.1*(longitude\"" . $this->longitude . "\")*" . cos($this->latitude/57.3) . "),\"2\")+pow((69.1*(latitude-\"" . $this->latitude . "\")),\"2\"))<(" . $radius * $radius . ") ";              $conn = &$globals["dbsettings"]->getconnection();             $rs = &$conn->execute($sql);             if ($rs === false)                 return -1;             $location_ids = array();             while (!$rs->eof)             {                 array_push($location_ids, $rs->fields[0]);                 $rs->movenext();             }             return $location_ids;         } 

found solution... missing - after longitude in equation...

it should

(pow((69.1*(longitude-\"" . $this->longitude . "\")" . cos($this->latitude/57.3) . "),\"2\")+pow((69.1(latitude-\"" . $this->latitude . "\")),\"2\"))<(" . $radius * $radius . ") ";


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -