Edited: (added table example)
With your help guys I\'m in this place that I have information in table ( Name, team, start time finish time and even time between these tw
you can work out the diff from leader by remembering the leaders time, and the previous time as you run through the loop.
lets add an elapsed_time into the query
SELECT
klass, nimi, synd, teamnimi, start,
TIME(`finish`) AS finish,
timediff(time(finish), time(start)) AS aeg,
finish - start as elapsed_time
FROM bc2014 T1
INNER JOIN bc2014aeg T2 on T1.bc2014_id = T2.bc2014_id
WHERE klass = 'DS1 (1 koera toukerattavedu al.14 a.)'
ORDER BY aeg
Then use this in the result set to calculate the time differences
while($row = $results->fetch_array()) {
//.....
if(isset($leader_time)){
print ''. $row["elapsed_time"] - $leader_time .'s ';
print ''. $row["elapsed_time"] - $last_time .'s ';
} else {
print ' ';
print ' ';
}
// ...
if(!isset($leader_time)){ $leader_time = $row["elapsed_time"] ;}
$last_time = $row["elapsed_time"] ;
}
you can then use $leader_time and $last_time to calculate the two difference columns