How can inactive status be implemented for articles in a PHP application to prevent accidental deletion of important data?

To prevent accidental deletion of important data in a PHP application, inactive status can be implemented for articles. This can be achieved by adding a column in the database table to store the status of each article (active or inactive). When an article is marked as inactive, it will not be displayed on the website but can still be accessed for reference or reactivation if needed.

// Database table structure
CREATE TABLE articles (
    id INT AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    content TEXT NOT NULL,
    status ENUM('active', 'inactive') NOT NULL DEFAULT 'active'
);

// Update article status to inactive
$articleId = 1; // ID of the article to be marked as inactive
$sql = "UPDATE articles SET status = 'inactive' WHERE id = :id";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':id', $articleId, PDO::PARAM_INT);
$stmt->execute();