Can you define totals or averages? If so, how?
Can you define totals or averages? If so, how?
should work with php
[wctphp]echo {field1} + {field2};[/wctphp]
Of corse, both field NEED to be set. if one field is not set, an error will occure.
Otherwise make it secure like:
[wctphp]$var1 = '{field1}';$var2 = '{field2}';$total = (integer)$var1 + (integer)$var2;echo $total;[/wctphp]
This will save 2 fields in 2 variables, change it to an integer and then add them together.
average:
[wctphp]$var1 = '{field1}';$var2 = '{field2}';$average = ((integer)$var1 + (integer)$var2)/2;echo $average;[/wctphp]
This is normal PHP Code.
Regards
Stefan
Nice, thank you Stefan.
Caps
Say that I wanted a grand total for each line item, how would I achieve this? Total =
with the code above, add this to the table setup in a field.
Will try that.
You must log in to post.