DEMO SITE v1.7.15

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

#CustomernameCityCreditlimitPaidProfit 
1Blauer See Auto, Co.Frankfurt59700$0.00
2Mini Wheels Co.San Francisco64600$0.00
3Land of Toys Inc.NYC114900$0.00
4Volvo Model Replicas, CoLuleå53100$0.00
5Danish Wholesale ImportsKobenhavn8340023459043.73$23,375,643.73
6Saveley & Henriot, Co.Lyon123900130305.9$6,405.90
7Dragon Souveniers, Ltd.Singapore10380050508.030000000006$-53,291.97
8Muscle Machine IncNYC138500177913.95$39,413.95
9Diecast Classics Inc.Allentown10060098509.25$-2,090.75
10Technics Stores Inc.Burlingame84600104545.22$19,945.22
Σ  7406300.1229964693.750000004$22,850,693.63 
Add Export into CSV Print
Search