Cumulative total will not work

For each record (row) I am getting numeric values from two functions. I then calculate a new value . I want to add all the values from each record to become one total . I use the += operator but it will not work. All other calculations work. Please help. The variable that I want to hold the grand total is :$nonaccruedays in the script below.

function numWorkingdaysNoAccural($emp_id,$company_code){
$result = mysql_query(“SELECT * FROM employee_leave
el inner JOIN leave_type_accrual lt ON lt.leave_type_id= el.leave_type_id
AND el.company_code =lt.company_code
WHERE el.emp_id=’$emp_id’ AND el.company_code = ‘$company_code’”);
if ($result) {
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
$row = mysql_fetch_array($result, MYSQL_BOTH) ;
$num_rows = mysql_num_rows($result);
if ($row[16] ==‘yes’&&($row[5]==‘0’) ){
$fromDate = $row[7];
echo “Fromdate=$fromDate”;
$toDate = $row[8];
echo “Todate=$toDate”;
$dayoffs = getNumOfDayOffs($emp_id, $fromDate,$toDate,$company_code);
echo “daysoff=$dayoffs” ;
$totaldays = getNumDays($start_date, $end_date);
echo “Totaldays=$totaldays”;
$workdaysblocked = ($totaldays-$dayoffs );
echo"workdaysblocked= $workdaysblocked";
$NonAccrueDays += $workdaysblocked ;
//echo “NonAcruedays=$NonAccrueDays”;harl

not sure what does what in your script, but you can do something like
$NonAccrueDays = $totaldays + $workdaysblocked[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service