What are some best practices for closing forum threads in PHP to maintain organization and prevent clutter?

Issue: Closing forum threads in PHP is important to maintain organization and prevent clutter. One way to do this is by setting a flag in the database to mark a thread as closed, and then filtering out closed threads from the display. PHP Code Snippet:

// Set a flag in the database to mark a thread as closed
$thread_id = 123; // ID of the thread to be closed
$status = 'closed'; // Status to mark the thread as closed
$query = "UPDATE threads SET status = '$status' WHERE id = $thread_id";
// Execute the query to update the status of the thread to 'closed'

// Filter out closed threads from the display
$query = "SELECT * FROM threads WHERE status != 'closed'";
// Execute the query to fetch only open threads for display