query($query); // Prepare the response data $data = []; while ($row = $result->fetch_assoc()) { $row['registrationtime'] = $row['time_diff_minutes'] . " minutes ago"; // Format time unset($row['time_diff_minutes']); // Remove the raw time difference value $data[] = $row; } // Send JSON response to the frontend echo json_encode([ "newRegistrations" => $data, "timestamp" => time() // Update the last poll timestamp ]); ?>