Subselect and sum row

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

HIDE CODE
<?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
Actions
1La Rochelle GiftNantes118200$0.00 View Edit Remove
2Baane Mini ImportsStavern81700274.52$-81,425.48 View Edit Remove
3Mini Gifts Distributors Ltd.San Rafael210500$0.00 View Edit Remove
4Blauer See Auto, Co.Frankfurt59700111$-59,589.00 View Edit Remove
5Mini Wheels Co.San Francisco646000$-64,600.00 View Edit Remove
6Land of Toys Inc.NYC1149000$-114,900.00 View Edit Remove
7Euro+ Shopping ChannelMadrid227600$0.00 View Edit Remove
8Volvo Model Replicas, CoLula53100$0.00 View Edit Remove
9Danish Wholesale ImportsKobenhavn83400$0.00 View Edit Remove
10Saveley & Henriot, Co.Lyon123900$0.00 View Edit Remove
Σ  7837700.125704140.126500001$-1,115,159.99 
Search