DEMO SITE v1.7.24

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 
1aZbyszek Zbyszek PiestrzeniewiczWarszawa1230$0.00 View Edit Remove
2Blauer See Auto, Co.Frankfurt5970075937.76000000001$16,237.76 View Edit Remove
3Mini Wheels Co.San Francisco6460066710.56$2,110.56 View Edit Remove
4Land of Toys Inc.NYC114900107639.94$-7,260.06 View Edit Remove
5Euro+ Shopping ChannelMadrid227600679486.64$451,886.64 View Edit Remove
6Volvo Model Replicas, CoLuleå5310036005.71$-17,094.29 View Edit Remove
7Danish Wholesale ImportsKobenhavn83400107446.5$24,046.50 View Edit Remove
8Saveley & Henriot, Co.Lyon123900130305.9$6,405.90 View Edit Remove
9Dragon Souveniers, Ltd.Singapore103800153639.19$49,839.19 View Edit Remove
10Muscle Machine IncNYC138500177913.95$39,413.95 View Edit Remove
Σ  8635130.1200000017770860.540000002$136,960.42 
Add Export into CSV Print Search