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
Add Export into CSV Print Execution time: 0.017 sMemory usage: 0.13 MB Search
| # | Customername | City | Creditlimit | Paid | Profit | |
|---|---|---|---|---|---|---|
| 1 | Atelier graphique rrr | Nantes | 21000 | 32413.120000000003 | $11,413.12 | View Edit Remove |
| 2 | Signal Gift Stores | Las Vegas | 71800 | 72063.85999999999 | $263.86 | View Edit Remove |
| 3 | Australian Collectors, Co. | Melbourne | 117300 | 180584.58 | $63,284.58 | View Edit Remove |
| 4 | La Rochelle Gifts | Nantes | 118200 | 116949.68000000001 | $-1,250.32 | View Edit Remove |
| 5 | Baane Mini Imports | Stavern | 81700 | 104224.79 | $22,524.79 | View Edit Remove |
| 6 | Mini Gifts Distributors Ltd. | San Rafael | 210500 | 584188.2400000001 | $373,688.24 | View Edit Remove |
| 7 | Zbyszek Zbyszek Piestrzeniewicz | Warszawa | 1230 | $0.00 | View Edit Remove | |
| 8 | Blauer See Auto, Co. | Frankfurt | 59700 | 75937.76000000001 | $16,237.76 | View Edit Remove |
| 9 | Mini Wheels Co. | San Francisco | 64600 | 66710.56 | $2,110.56 | View Edit Remove |
| 10 | Land of Toys Inc. | NYC | 114900 | 107639.94 | $-7,260.06 | View Edit Remove |
| Σ | 8255630.12 | 8855820.930000002 | $601,420.81 |
?>