What alternative methods can be used to store standard text that needs to be dynamically updated on a website?

When standard text on a website needs to be dynamically updated, one alternative method to store this text is to use a database to store the text content. By storing the text in a database, it can be easily updated and retrieved using SQL queries. This allows for dynamic content management without the need to edit the website's code directly.

<?php
// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

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

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

// Retrieve the text content from the database
$sql = "SELECT text_content FROM website_text WHERE id = 1";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Output data of each row
    while($row = $result->fetch_assoc()) {
        echo $row["text_content"];
    }
} else {
    echo "0 results";
}

$conn->close();
?>