Hello,

In my database, I have two variables "longitude" and "latitude". I use a function to know the distance between the user and the element in my database, for instance a touristic site.

The problem is to order results knowing that my distance variable ($longueur) is defined in my while loop for each result so i can't use a ORDER BY

Thanks in advance for your tips

PHP Code:
<?php
$query
="SELECT * FROM matable WHERE Statut>='0'";
$db->setQuery($query);
$rs=$db->query();
function 
get_distance_m($Lat$Long$user_Lat$user_Long) {...}
while(
$row=mysqli_fetch_array($rs)){
$Lat=$row['Lat'];
$Long=$row['Long'];
$longueur=round(get_distance_m($Lat$Long$user_Lat$user_Long) / 10003);
?>
... HTML Code ...