Welcome Guest, Not a member yet? Register   Sign In
calculate difference between database-rows on output in an easy way?
#2

[eluser]Shay Falador[/eluser]
Well, the database library lets you fetch the results as an array.
So, just walk over it backwards and do the math:
Code:
$result = $query->result();
for($i = count($result) - 1; $i > 0; $i--) {
    $results[$i]['diff'] = $results[$i]['value'] - $results[$i - 1]['value'];
}

I think this one would work!


Messages In This Thread
calculate difference between database-rows on output in an easy way? - by El Forum - 02-06-2010, 02:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB