How can the $_GET variable be utilized to retrieve specific data for display on a new page in a PHP forum thread system?

To retrieve specific data for display on a new page in a PHP forum thread system using the $_GET variable, you can pass an identifier through the URL and use it to fetch the corresponding data from a database. For example, you can pass the thread ID as a parameter in the URL and then use it to query the database for the thread details to display on the new page.

// Retrieve the thread ID from the URL
$thread_id = $_GET['thread_id'];

// Query the database to fetch the thread details
// Assuming $db is your database connection
$query = "SELECT * FROM threads WHERE id = $thread_id";
$result = mysqli_query($db, $query);

// Display the thread details on the new page
if(mysqli_num_rows($result) > 0) {
    $thread = mysqli_fetch_assoc($result);
    echo "<h1>{$thread['title']}</h1>";
    echo "<p>{$thread['content']}</p>";
} else {
    echo "Thread not found.";
}