Status: get_promotion_status(); if ($promoteAll[0]['promote_all']==0) { # code... $over_all_position = $admission->overall_position($student['form_id'],$semester_id,$a_year_id); if ($over_all_position) { $i=0; foreach ($over_all_position as $over_all_position) { $i++; if ($over_all_position['student_id']==$student['student_id']) { if (($over_all_position['total_score']/900)*100<40) { echo "Repeated"; }else{ echo "Promoted"; if ($semester_id==3) { $promoted_to = $student['class']+1; $data = array("class"=>$promoted_to); $admission->update($data,$student['student_id']); } } } } } }else{ if ($semester_id==3) { $promoted_to = $student['class']+1; $data = array("class"=>$promoted_to); $admission->update($data,$student['student_id']); } } ?>