Php 如何使用codeigniter在表的页脚中打印总计

Php 如何使用codeigniter在表的页脚中打印总计,php,json,codeigniter,Php,Json,Codeigniter,我正在使用codeigniter框架。如何在页脚的“采购订单”列中获取总计 $return_array[] = array( 'brand_name'=>$row->brand_name, 'product_type'=>$row->product_type, 'product_flavour'=>$row->product_flavour, 'dealer_price'=>$dealer_price, 'pric

我正在使用codeigniter框架。如何在页脚的“采购订单”列中获取总计

$return_array[] = array(
    'brand_name'=>$row->brand_name,
    'product_type'=>$row->product_type,
    'product_flavour'=>$row->product_flavour,
    'dealer_price'=>$dealer_price,
    'price'=>$price ,
    'openStock'=>$openStock,
    'total_purchase'=>$toatal_purchase,
    'free_issuese_in'=>$free_issuese_in,   
    'stock_tra_in'=>$stock_tra_in,
    'tot'=> number_format(count($openStock) > 0 ? $openStock[0]->openStock:0,2)+($toatal_purchase[0]->totalPurchase)+($free_issuese_in[0]->freeIssueseIn)+($stock_tra_in[0]->stocktrain),//total
    'totalsales'=>$totalSales,
    'stockTraOut'=>$stockTraOut,
    'freeIssuesOut'=>$freeIssuesOut,
    'clossing_blnc'=>  number_format(count($stockTraOut)> 0 ? $stockTraOut[0]->stockTraOut :0,2)+( $freeIssuesOut[0]->freeIssuesOut)+($totalSales[0]->totalsales)-(number_format(count($openStock) > 0 ? $openStock[0]->openStock:0,2)+($toatal_purchase[0]->totalPurchase)+($free_issuese_in[0]->freeIssueseIn)+($stock_tra_in[0]->stocktrain))//closing balance
);
我将这些数据传递给身体。。。。。。此处第7列为总采购列。我想为另一个id的页脚获取和的列数据。我使用json解析传递这些数据

for( var x=0; x<order.length;x++) {
    order_detail.push(
        '<tr>'
         +'<td>'+ order[x].brand_name + '</td>'
         +'<td>'+ order[x].product_type + '</td>'
         +'<td>'+ order[x].product_flavour +'</td>'
         +'<td id="mm">' + order[x].dealer_price[0].dealer_price +'</td>'
         +'<td id="yy"  style="display:none;">' + order[x].price[0].price+'</td>'
         +'<td>' + order[x].openStock[0].openStock +'</td>'
         +'<td>' + order[x].total_purchase[0].totalPurchase+'</td>'
         +'<td>'+ order[x].free_issuese_in[0].freeIssueseIn + '</td>'
         +'<td>'+ order[x].stock_tra_in[0].stocktrain + '</td>'
         +'<td>' + order[x].tot+'</td>'
         +'<td>' + order[x].totalsales[0].totalsales+'</td>' 
         +'<td>'+ order[x].stockTraOut[0].stockTraOut + '</td>'
         +'<td>'+ order[x].freeIssuesOut[0].freeIssuesOut + '</td>'
         +'<td>'+ order[x].clossing_blnc + '</td>'
         +'</tr>'
   );

}
sweetAlert("Good job!", "monthly stock Succsessfully filter !", "success");
//  $j('#lbl_rescount').text('0');
//  $j('#sl_amount').text(order['totals_td'][0].tot_purchase);

// $j('#sl_amount').html(tot1);
$j('#order_body').html(order_detail);

for(var x=0;x首先,您的原始帖子令人困惑。您首先展示PHP,然后是JS,让我们来假设很多事情

我的假设是,首先在控制器中创建
$return\u数组
,然后将其传递给视图。然后在视图中,以某种方式将其传递给JS。是否使用AJAX?是否将此信息直接传递给PHP视图

如果您使用的是AJAX,然后使用
JSON.parse()
$return\u array[]
转换为
order
,那么为什么不执行以下操作呢

var total = 0;
for( var x=0; x<order.length;x++) {
    total+= order[x].total_purchase[0].totalPurchase;
    order_detail.push(
        //your table code
   );

}
$("footer").html(total);
var总计=0;

对于(var x=0;XY)我们的问题不清楚我想在采购订单列中获取总计…在表尾…如何编码…在数组函数内的模型文件中,我无法计算采购总额。。。。