$json = $acc->userCourseDesignationReports(); echo $json; } else { if ($action == 'GetUserReportStateFilter') { $acc = new UserAccounts(); $json = $acc->userCourseStateReports(); echo $json; } else { if ($action == 'GetUserReportCourseNameFilter') { $acc = new UserAccounts(); $json = $acc->userCourseCourseNameReports(); echo $json; } else { if ($action == 'GetAdminUserReports') { $acc = new UserAccounts(); $json = $acc->userCourseReports(); $dejson = json_decode($json); $data = "{\"data\": ["; for ($ind = 0; $ind < count($dejson); $ind++) { $data .= "["; $data .= "\"" . $dejson[$ind]->{'firstName'} . " " . $dejson[$ind]->{'lastName'} . "\","; $data .= "\"" . $dejson[$ind]->{'designation'} . "\","; $data .= "\"" . $dejson[$ind]->{'courseName'} . "\","; $data .= "\"" . $dejson[$ind]->{'testType'} . "\","; $data .= "\"" . $dejson[$ind]->{'marksResults'} . "\""; $data .= "],"; } $data = chop($data, ","); $data .= "]}"; echo $data; }