Here is my problem, I am creating a body fat and muscle gain tracker that will need to perform simple math based on data previously entered. I'll try my best to give an example without confusing whoever reads this post.

Someone would enter a weight of 214 lbs and 28.6% body-fat into my web form and then click on the save button, which would save and automatically redirect them to a table which shows their total results, which in this case would be 214 total pounds, 28.6% body-fat, 152.8 lean mass, and 61.2 pounds of fat which is automatically calculated. I know how to do all of this and this works out just fine. The problem arises when they would come back the following week and each week thereafter and enter their new results. For example:

Next week, after exercising, dieting and lifting weights their weight would be 212 pounds and 27.7% body-fat, so their new lean mass would be 153.8 pounds and their new total fat would be 58.7 pounds. This means they would have lost 2.5 pounds of fat and gained about .5 pound of muscle in the week. So basically the table would look something like this:

weight bf% t-fat t-lean fat loss muscle gain
214 | 28.6 | 161.2 | 152.8 | n/a | n/a
212 | 27.7 | 158.7 | 153.3 | -2.48 | 0.48
210 | 25.5 | 153.5 | 156.5 | -5.17 | 3.17
205 | 23.7 | 148.6 | 160.3 | -4.9 | -0.04

The problem is that my table is being generated using a while loop which so I don't know how I would assign variables to "fat lost" and "muscle gained" because those last two values are simply adding or subtracting themselves from the info entered the previous week of this example; and with while loops the <table> and </table> tags are outside of the loop and the single <tr> row with all the <td></td> columns would be the single line generated as long as values are still available to be entered; so in the while loop I don't know how to refer back to the previously entered values after the loop curser has moved down and entered the next table row or results.

I really hope I didn't confuse everyone, it actually took me almost an hour to write this post. Help please?