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 | Mini Gifts Distributors Ltd. | San Rafael | 210500 | 461489.54 | $250,989.54 | View Edit Remove |
2 | aZbyszek Zbyszek Piestrzeniewicz | Warszawa | 1230 | $0.00 | View Edit Remove | |
3 | Blauer See Auto, Co. | Frankfurt | 59700 | 75937.76000000001 | $16,237.76 | View Edit Remove |
4 | Mini Wheels Co. | San Francisco | 64600 | 66710.56 | $2,110.56 | View Edit Remove |
5 | Land of Toys Inc. | NYC | 114900 | 107639.94 | $-7,260.06 | View Edit Remove |
6 | Euro+ Shopping Channel | Madrid | 227600 | 679486.64 | $451,886.64 | View Edit Remove |
7 | Volvo Model Replicas, Co | Luleå | 53100 | 36005.71 | $-17,094.29 | View Edit Remove |
8 | Danish Wholesale Imports | Kobenhavn | 83400 | 107446.5 | $24,046.50 | View Edit Remove |
9 | Saveley & Henriot, Co. | Lyon | 123900 | 130305.9 | $6,405.90 | View Edit Remove |
10 | Dragon Souveniers, Ltd. | Singapore | 103800 | 156251.03 | $52,451.03 | View Edit Remove |
Σ | 8845630.120000001 | 8234961.920000003 | $390,561.80 |