$_POST['identificador'],
"fecha" => $_POST['fecha'],
"kms" => $_POST['kms'],
"litros" => str_replace(',', '.',$_POST['litros']),
"descuento" => str_replace(',', '.',$_POST['descuento']),
"precioxlitro" => str_replace(',', '.',$_POST['precioxlitro']),
"importe" => str_replace(',', '.',$_POST['importe'])
];
$sql = "UPDATE carburante
SET identificador = :identificador,
fecha = :fecha,
kms = :kms,
litros = :litros,
descuento = :descuento,
precioxlitro = :precioxlitro,
importe = :importe
WHERE identificador = :identificador";
$statement = $connection->prepare($sql);
$statement->execute($kms);
} catch(PDOException $error) {
echo $sql . "
" . $error->getMessage();
}
}
if (isset($_GET['identificador'])) {
try {
$connection = new PDO($dsn, $username, $password, $options);
$identificador = $_GET['identificador'];
$sql = "SELECT * FROM carburante WHERE identificador = :identificador";
$statement = $connection->prepare($sql);
$statement->bindValue(':identificador', $identificador);
$statement->execute();
$kms = $statement->fetch(PDO::FETCH_ASSOC);
} catch(PDOException $error) {
echo $sql . "
" . $error->getMessage();
}
} else {
echo "¡Algo ha salido mal!";
exit;
}
?>
successfully updated.