使用PHP更新MYSQL数据库中的记录

I have a database consists of 7 column (RequestID,Meal,Name,Address,City,Phone,Email,Status)

I wanna update the status of my Requests by entering the RequestID then the new status

I'm having a problem

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'aa' in 'field list

if (isset($_POST['update'])) {
// $RequestID = $_POST['RequestID'];

    $RequestID = $_POST['RequestID'];

    $Status = $_POST['Status'];

// mysql query to Update data

    $conn->beginTransaction();
    $conn->exec("UPDATE delivery SET delivery.Status = $Status WHERE delivery.RequestID = $RequestID ");

    $conn->commit();

    echo "<h1 style=text-center;>Status updated</h1>";
    echo "<br>";
}

<!DOCTYPE html>

<html>

<head>

    <title> PHP UPDATE STATUS </title>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>

<body>

    <form action="tests.php" method="post">

        ID To Update: <input type="number" name="RequestID" required><br><br>

        New Status:<input type="text" name="Status" required><br><br>

        <input type="submit" name="update" value="Update Data">

    </form>

</body>

The error message indicates that the table admin in your database does not have a column called 'aa'. You need to check what columns are available in the table, but without more information (such as the table definition), I can't be more help.

Change your sql code as following:

$conn->exec("UPDATE `delivery` SET `Status` = `$Status` WHERE `RequestID` = `$RequestID` ");

Please try this method to execute the query.

$conn->exec($con,"UPDATE `delivery` SET `Status` = '$Status' WHERE `RequestID` = $RequestID");

From your comment I assume the field Status is a string and the RequestID is an int. So this should work fine for you.

$sql = "UPDATE delivery SET Status = '".$Status."' WHERE RequestID = ".$RequestID;
$conn->exec($sql);