This topic is locked
[SOLVED]

 column calculation

12/2/2011 11:54:50 AM
PHPRunner General questions
P
piobote author

Dear all,
I note the counter of machine A in a table that looks like this:
date ==== counter

10/10/2011 === 500

10/11/2011 === 1500

10/12/2011 === 2500
How can I do to get this result:
date=== counter === Delta

10/10/2011=== 500 === 0

09/11/2011=== 1200 ==== 700

10/12/2011=== 2500 ==== 1300

31/12/2011=== 2900 ==== 400
Delta = (new counter value - old value )
Please help me

C
cgphp 12/2/2011

In the "List page: before record processed" event enter this code:

if(isset($_SESSION['prev']))

{

$data['Delta'] = $data['counter'] - $_SESSION['prev'];

$_SESSION['prev'] = $data['counter'];

}

else

{

$data['Delta'] = 0;

$_SESSION['prev'] = $data['counter'];

}
return true;


In the "Before display" event of the list page enter this code:

unset($_SESSION['prev']);
P
piobote author 12/2/2011

Thank you Cristian, you are the best!