Subselect and sum row Default theme

Subselect() will create a new column with some value from other (or current) table. You can use any columns from current tables as parameters. Subselect will be called for each row

<?php
	$xcrud = Xcrud::get_instance();
    $xcrud->table('customers');
    $xcrud->columns('customerName,city,creditLimit,Paid,Profit'); // specify only some columns
    $xcrud->subselect('Paid','SELECT SUM(amount) FROM payments WHERE customerNumber = {customerNumber}'); // other table
    $xcrud->subselect('Profit','{Paid}-{creditLimit}'); // current table
    $xcrud->sum('creditLimit,Paid,Profit'); // sum row(), receives data from full table (ignores pagination)
    $xcrud->change_type('Profit','price','0',array('prefix'=>'$')); // number format
    echo $xcrud->render();
?>

Customers

#CustomernameCityCreditlimitPaidProfit 
1Atelier graphiqueNantes2100022314.36$1,314.36
2Signal Gift StoresLas Vegas7180080180.98$8,380.98
3Australian Collectors, Co.Melbourne117300180585.07$63,285.07
4La Rochelle GiftsNantes118200116949.68$-1,250.32
5Baane Mini ImportsStavern81700104224.79$22,524.79
6Mini Gifts Distributors Ltd.San Rafael210500584188.24$373,688.24
7Havel & Zbyszek CoWarszawa0$0.00
8Blauer See Auto, Co.Frankfurt5970075937.76$16,237.76
9Mini Wheels Co.San Francisco6460066710.56$2,110.56
10Land of Toys Inc.NYC114900107639.94$-7,260.06
Σ  8254400.128853839.23$599,439.11 
Add Export into CSV PrintSearch

 
Buy it nowfor only $13