<?php
// Database connection
$servername = "localhost";
$username = "antenicenefather_anf";
$password = "363213119.363213119";
$dbname = "antenicenefather_anf";

// Connect to the database
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Receive Row ID from AJAX request
$data = json_decode(file_get_contents('php://input'), true);
$rowId = $conn->real_escape_string($data['rowId']);

// SQL to fetch the row
$sql = "SELECT gpt_response_1, gpt_response_2, gpt_response_3, gpt_response_5 FROM longform WHERE id = '{$rowId}'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Fetch data
    $row = $result->fetch_assoc();
    $combinedData = str_replace("'", "", $row['gpt_response_1'].$row['gpt_response_2'].$row['gpt_response_3'].$row['gpt_response_5']);
    echo $combinedData;
} else {
    echo "No data found";
}

$conn->close();
?>
