I am building an e-shop, and I want to update the reserve on products in the database but the code is not working properly. Can you check it out, please
if (filter_input(INPUT_GET,'checkout')){
$sql="UPDATE tblproduct SET apothema=18 WHERE id=1"}
if (filter_input(INPUT_GET,'checkout')){
$sql="UPDATE tblproduct SET apothema=18 WHERE id='1'";
// connect to database to run your query so the above query will execute
$run = $conn->query($sql);
//this is optional
//you can use like this to check if your connect is success and data is inserted.
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
I think the problem is only here WHERE id = '1' ";
remember that you need to use that'value to compare'
and don't forgot to put ;
in the end too. One more thing, you need to connect to database and run query to insert data to your database.