<?php
$servername = "localhost";
$username = "u836566291_pcs";
$password = "VSJgO:Y8=rZ";
$dbname = "u836566291_pcs";

try {
    $con = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    if (isset($_POST['id']) && isset($_POST['column']) && isset($_POST['value'])) {
        $id = $_POST['id'];
        $column = $_POST['column'];
        $value = $_POST['value'];

        $update = $con->prepare("UPDATE `data` SET `$column` = :value WHERE id = :id");
        $update->bindParam(':value', $value);
        $update->bindParam(':id', $id);
        if ($update->execute()) {
            echo 'success';
        } else {
            echo 'error';
        }
    }
} catch (PDOException $e) {
    echo "error:" . $e->getMessage();
}
?>
