Subselect and sum row Bootstrap 4.5 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 | Atelier graphiques | Nantes | 510000 | 14191.12 | $-495,808.88 | View Edit Remove |
2 | Australian Collectors, Co. | Melbourne | 117300 | $0.00 | View Edit Remove | |
3 | La Rochelle Gifts | Nantes | 118200 | $0.00 | View Edit Remove | |
4 | Baane Mini Imports | Stavern | 81700 | $0.00 | View Edit Remove | |
5 | Mini Gifts Distributors Ltd. | San Rafael | 210500 | $0.00 | View Edit Remove | |
6 | Zbyszek Zbyszek Piestrzeniewicz | Warszawa | 1230 | $0.00 | View Edit Remove | |
7 | Blauer See Auto, Co. | Frankfurt | 59700 | 24443 | $-35,257.00 | View Edit Remove |
8 | Mini Wheels Co. | San Francisco | 64600 | 201 | $-64,399.00 | View Edit Remove |
9 | Land of Toys Inc. | NYC | 114900 | 201 | $-114,699.00 | View Edit Remove |
10 | Euro+ Shopping Channel | Madrid | 227600 | 421216.23 | $193,616.23 | View Edit Remove |
Σ | 8672830.120000001 | 7231993.1400000015 | $-911,906.98 |