What are some potential pitfalls of storing news entries in separate .txt files for each day?

One potential pitfall of storing news entries in separate .txt files for each day is that it can become cumbersome to manage and retrieve the data efficiently. A better approach would be to store the news entries in a database, allowing for easier querying and organization of the data.

// Connect to database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "news_database";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Query to retrieve news entries
$sql = "SELECT * FROM news_entries";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Output data of each row
    while($row = $result->fetch_assoc()) {
        echo "Title: " . $row["title"]. " - Content: " . $row["content"]. "<br>";
    }
} else {
    echo "0 results";
}

$conn->close();