'Retrieve the value of the SUM function at each round of while loop PHP SQL

this is the first time I ask a question on a forum so excuse me in advance if you have difficult to understand my request.

 $somm = 'SELECT SUM(lenght- start) FROM gantt WHERE ' . $id['idValeur'] < 2 . '';

I get $id['idValue'] at each round of while loop and I would like that at each round of loop I can have access to the result of SUM(length - start) for example, for an id of 2, I want to have in response (length1 - start1 + length2 - stat2) = result

First of all, is it possible? If so, what should I go for.

Thanks in advance :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source