lastErrorMsg()); } // Prepare and execute the SQL UPDATE query $updateQuery = "UPDATE projects SET projectname = :projectname, erfno = :erfno, allotment = :allotment, client = :client, clientid = :clientid, clientprogress = :clientprogress WHERE id = :id"; $stmt = $db->prepare($updateQuery); if (!$stmt) { die("Prepare failed: " . $db->lastErrorMsg()); } $stmt->bindValue(':projectname', $updatedData['projectname'], SQLITE3_TEXT); $stmt->bindValue(':erfno', $updatedData['erfno'], SQLITE3_TEXT); $stmt->bindValue(':allotment', $updatedData['allotment'], SQLITE3_TEXT); $stmt->bindValue(':client', $updatedData['client'], SQLITE3_TEXT); $stmt->bindValue(':clientid', $updatedData['clientid'], SQLITE3_INTEGER); $stmt->bindValue(':clientprogress', $updatedData['clientprogress'], SQLITE3_TEXT); $stmt->bindValue(':id', $projectId, SQLITE3_INTEGER); $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); } } ?>