I would like to find total outstanding arrears for each doctor and display the result.
my controller
public function pay_salaries()
{
$salary['salaries'] = $this->db->query("SELECT * FROM salaries WHERE Payment_status IS NULL ORDER BY Salary_id DESC")->result_array();
$this->load->view('backend/admin/pay_salaries',$salary);
}
This controller really does so well until I want to echo all arrears for a doctor
view
<thead>
<tr>
<th>DOCTOR'S NAME</th>
<th>TOTAL PENDING AMOUNT</th>
</tr>
</thead>
<tbody>
<?php foreach ($salaries as $salary):
$doctor_id = $salary['doctor_id'];
$doctor_name = $this->db->query("SELECT * FROM user_details,doctors WHERE Doctor_id='$doctor_id' AND User_details_User_id=User_id")->row_array();
$total_outstanding_amount = $this->db->query("SELECT SUM(Amount) AS Arrears FROM salaries WHERE Payment_status IS NULL AND doctor_id = '$doctor_id'")->result_array();
?>
<tr>
<td><?php echo $doctor_name['Fname'].' '.$doctor_name['Sname']; ?></td>
<td><?php echo $total_outstanding_amount['Arrears']; ?></td>
</tr>
<?php endforeach ?>
</tbody>
total i expect in Arrears should be 5500+500 = 6000
I can't figure this out in a day. Please help... Thanks in advance
The error I keep getting is
Severity: Notice
Message: Undefined index: Arrears
Filename: admin/pay_salaries.php
Line Number: 79
Backtrace:
File: C:\wamp64\www\Alphadoctors\application\views\backend\admin\pay_salaries.php
Line: 79
Function: _error_handler