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 
1cocacola2$0.00
2Mini Wheels Co.San Francisco64600$0.00
3Land of Toys Inc.NYC11490033333$0.00
4fdfgdfgdfg$0.00
5Volvo Model Replicas, CoLuleå-50$0.00
6Danish Wholesale ImportsKobenhavn83400$0.00
7Saveley & Henriot, Co.Lyon123900130305.99$6,405.99
8Dragon Souveniers, Ltd.Singapore10380047516.04$-56,283.96
9Muscle Machine IncNYC138500177913.95$39,413.95
10Diecast Classics Inc.Allentown10060098509.25$-2,090.75
Σ  11497113983.126308120.8500000015$-625,813.27 
Add Export into CSV Print
Search