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

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 
1Volvo Model ReplicasLuleå53100$0.00
2xxxxxx1154.15$153.15
3Saveley & Henriot, Co.Lyon123900$0.00
4steveSingapore103800$0.00
5Muscle Machine IncNYC138500$0.00
6Diecast Classics Inc.Allentown100600$0.00
7Technics Stores Inc.Burlingame8460011$-84,589.00
8Handji Gifts& CoSingapore97900$0.00
9Herkku GiftsBergen96800$0.00
10JoeNew Haven0$0.00
Σ  7093701.124517349.13$-890,551.99 
Add Export into CSV Print Search