I have a table which has complete route co-ordinates (lat/lon). The data is of every 0.5 meters. I want to calculate distance between every two points and put the result in distance column of mysql table:
Lat lon Distance 12.9994 77.66645 0 12.9874 77.76888 0.5 12.8977 77.88404 1.0 12.7899 11.87999 1.5
I have written a function in php to calculate like GetDist($lat1,$lon1,$lat2,$lon2), but the issue is every time  $lat1,$lon1,$lat2,$lon2 has to be fetched from mysql  and after coming out of the function $lat1 should be updated with $lat2 and $lon1 should be updated with $lon2 and $lat2/$lon2 should acquire new data from Mysql.
Can anyone help me on how to I do this?
Thanks
 
     
     
    