���� ������������������������������������ 'error', 'message' => 'ClientPointId is required as a URL parameter.' ]); exit; } // Get the ClientPointId from the URL $ClientPointId = $_GET['ClientPointId']; try { // Create a PDO instance for database connection $pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Prepare the SQL query to fetch the `data` column for the given ClientPointId $stmt = $pdo->prepare(" SELECT data FROM webhookdata_3398 WHERE ClientPointId = :ClientPointId "); // Bind the ClientPointId parameter $stmt->bindValue(':ClientPointId', $ClientPointId, PDO::PARAM_INT); // Execute the query $stmt->execute(); // Fetch all rows as an associative array $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // Check if any data was found if (empty($rows)) { // Return a 404 error if no data is found http_response_code(404); // Not Found echo json_encode([ 'status' => 'error', 'message' => 'No data found for the provided ClientPointId.' ]); } else { // Extract the `data` column values and decode them from JSON $combinedData = []; foreach ($rows as $row) { $combinedData[] = json_decode($row['data'], true); } // Return the combined data in JSON format http_response_code(200); // OK echo json_encode([ 'status' => 'success', 'data' => $combinedData ]); } } catch (PDOException $e) { // Handle database errors http_response_code(500); // Internal Server Error echo json_encode([ 'status' => 'error', 'message' => 'Database error: ' . $e->getMessage() ]); } ?>