DEMO SITE v1.7.15

Subselect and sum row Minimal 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

	$xcrud = Xcrud::get_instance();
    $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();


1Mini Wheels Co.San Francisco64600$0.00
2Land of Toys Inc.NYC11490033333$0.00
4Volvo Model Replicas, CoLuleå-50$0.00
5Danish Wholesale ImportsKobenhavn83400$0.00
6Saveley & Henriot, Co.Lyon123900130305.9$6,405.90
7Dragon Souveniers, Ltd.Singapore10380047516.04$-56,283.96
8Muscle Machine IncNYC138500177913.95$39,413.95
9Diecast Classics Inc.Allentown10060098509.25$-2,090.75
10Technics Stores Inc.Burlingame84600102110.97$17,510.97
Σ  11497113983.126308120.760000002$-625,813.36 
Add Export into CSV Print Search