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
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
# | Customername | City | Creditlimit | Paid | Profit | |
---|---|---|---|---|---|---|
1 | Muscle Machine Inc | NYC | 138500 | $0.00 | View Edit Remove | |
2 | Diecast Classics Inc. | Allentown | 100600 | $0.00 | View Edit Remove | |
3 | Technics Stores Inc. | Burlingame | 84600 | $0.00 | View Edit Remove | |
4 | Gift Depot Inc. | Bridgewater | 84300 | $0.00 | View Edit Remove | |
5 | Osaka Souveniers Co. | Kita-ku | 81200 | $0.00 | View Edit Remove | |
6 | Vitachrome Inc. | NYC | 76400 | 1 | $-76,399.00 | View Edit Remove |
7 | Toys of Finland, Co. | Helsinki | 96500 | 135 | $-96,365.00 | View Edit Remove |
8 | AV Stores, Co. | Manchester | 136800 | $0.00 | View Edit Remove | |
9 | Clover Collections, Co. | Dublin | 69400 | $0.00 | View Edit Remove | |
10 | Auto-Moto Classics Inc. | Brickhaven | 23000 | $0.00 | View Edit Remove | |
Σ | 6334555.12 | 4823326.960000001 | $-513,273.16 |