lastErrorMsg()); } $invoicefull = $updatedData['invoicefull']; if ($updatedData['status'] == "unpaid"){ $status = "paid"; } else { $status = "unpaid"; } // Prepare and execute the SQL UPDATE query $updateQuery = "UPDATE figures SET status = :status WHERE invoicefull = :invoicefull"; $stmt = $db->prepare($updateQuery); if (!$stmt) { die("Prepare failed: " . $db->lastErrorMsg()); } $stmt->bindValue(':invoicefull', $updatedData['invoicefull'], SQLITE3_TEXT); $stmt->bindValue(':status', $status, SQLITE3_TEXT); $result = $stmt->execute(); if (!$result) { die("Execute failed: " . $db->lastErrorMsg()); } // Close the database connection and the prepared statement $stmt->close(); $db->close(); $response = ['success' => true]; echo json_encode($response); } else { $response = ['success' => false]; echo json_encode($response); } } ?>