title: MYSQL select MIN distance beetween latitude and Longitude
body: <p>I have a table that contains column called func_id , latitude and longitude. Im trying to get the min distance row and return the func_id by a function. </p>
  
  <p>I tried:</p>
  
  <pre><code> function Get_Min_func_id($lat, $long){
          $query = mysql_query("
   select func_id,
     MIN( 3959 * acos( cos( radians('$lat') ) 
            * cos( radians( latitude ) ) 
            * cos( radians( longitude ) - radians('$long') ) 
            + sin( radians('$lat') ) 
            * sin( radians( latitude ) ) ) )  AS distance 
  from entregas 
  ");
  
    return @mysql_result($query, 0, 'func_id');
    }
  </code></pre>
  
  <p>But its not working fine. It is returning only the same func_id.</p>