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 
1Baane Mini ImportsStavern81700$0.00
2Mini Gifts Distributors Ltd.San Rafael210500$0.00
3Zbyszek Zbyszek PiestrzeniewiczWarszawa1230$0.00
4Blauer See Auto, Co.Frankfurt59700$0.00
5Mini Wheels Co.San Francisco64600$0.00
6Euro+ Shopping ChannelMadrid227600$0.00
7Volvo Model Replicas, CoLuleå53100$0.00
8Danish Wholesale ImportsKobenhavn83400154.15$-83,245.85
9Saveley & Henriot, Co.Lyon123900$0.00
10Dragon Souveniers, Ltd.Singapore103800$0.00
Σ  7812430.125684344.8100000005$-878,555.31 
Add Export into CSV Print
Search