How can a database entry be displayed for a limited time using PHP?

To display a database entry for a limited time using PHP, you can add a timestamp column in your database table to store the expiration time of the entry. Then, in your PHP code, you can query the database for entries that have not expired based on the current time.

<?php
// Connect to your database
$connection = mysqli_connect("localhost", "username", "password", "database");

// Get current time
$current_time = time();

// Query to select entries that have not expired
$query = "SELECT * FROM entries WHERE expiration_time > $current_time";
$result = mysqli_query($connection, $query);

// Display the entries
while($row = mysqli_fetch_assoc($result)) {
    echo $row['entry_content'] . "<br>";
}

// Close the database connection
mysqli_close($connection);
?>