This topic is locked
[SOLVED]

 Creating Totals Query

7/11/2011 5:53:56 PM
PHPRunner General questions
A
ant author

Can someone please assist or direct me in how to create totals for a specific query using PHPrunner

C
cgphp 7/11/2011
A
ant author 7/11/2011

Thank you for the quick response, it seems you have to do one total per field at at time. Managed to get through them all as I had about 10 fields I needed totaled. Is there a way I can get a do a formula deleting one total from another.
-----------------------------------------

You can add totals calculation to some fields on the list/printer-friendly pages. Totals calculation is available with horizontal layout only. You can choose between TOTAL, AVERAGE and COUNT aggregate functions. To do it select the field/fields you want to add totals calculation to and choose function type from Totals type drop-down box.

C
cgphp 7/12/2011

In the "List page: Before process" event:



global $conn;
$strSQL = "SELECT sum(first_field) AS tot1, sum(second_field) AS tot2, sum(third_field) as tot3 FROM your_table_name";

$rs = db_query($strSQL,$conn);

$data = db_fetch_array($rs);
$_SESSION['total'] = $data['tot1'] + $data['tot2'] + $data['tot3'];