我正在使用代码点火器,我尝试向结果数组添加$finalamount。
$this->db->select('customer_id, customer_ref, i_points, group_points, created_on');
$run_q = $this->db->get('employees');
if($run_q->num_rows() > 0){
foreach ($run_q->result_array() as $get) {
$totalpoints = $get['i_points'] + $get['group_points'];
$percent = 17;
$amountbycustomer = $totalpoints * 26 * $percent;
$amountbypref = $this->final($get['customer_id'],$percent);
$finalamount = $amountbycustomer + $amountbypref;
$get['finalamount'] = $finalamount;
}
return $run_q->result_array();
}
但在我看来,这个错误
<td class="employeeCustomer"><?=$get['customer_id']?></td>
<td class="employeeCustomerRef"><?=$get['customer_ref']?></td>
<td class="employeeAmount"><?=$get['finalamount']?></td>//line 65
消息:未定义索引:finalamount
文件名:employees/employeeslist.php
行号:65
1条答案
按热度按时间vngu2lb81#
您只是从db返回结果数组,而不是实际地将最终数量添加到各个行中。你必须这样做:
或使用参考传递(注意:
&get
):