// Lets cast provided float to float type to prevent sql injections
$float = (float) $_GET['float'];
$requst = mysql_query("SELECT * FROM floats WHERE float LIKE'$float.%%%%%%%' AND float2 LIKE'$float2.%%%%%%%'");
$array = array();
while ($r = mysql_fetch_array($requst)) {
// Lets store an array of differences between the provided float
// and db floats, indexed by db float value
$array[$r['float']] = abs($r['float'] - $float);
}
// Now lets sort the array by values(differences)
// keeping the keys intact
asort($array);
// The first key of the resulting array is the closest float to the provided float
$closest = array_pop(array_keys($array));