query($getUserQuery); if ($getUser->num_rows > 0) { $user_array = []; while ($user = $getUser->fetch_object()) { $user_array[] = array( 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'email' => $user->email, 'contact_number' => $user->contact_number, 'created_date' => $user->created_date, 'location' => $user->location, 'resume_file' => $user->resume_file, ); } $response["MESSAGE"] = "Get all contact data"; $response["CODE"] = 200; $response["DATA"] = $user_array; } else { $response["MESSAGE"] = "contact does not exist"; } } else { $response["MESSAGE"] = "INVALID REQUEST"; } echo json_encode($response);