How can HTML code be stored and retrieved from a MySQL database using PHP?

To store HTML code in a MySQL database using PHP, you can use the `mysqli_real_escape_string` function to escape special characters before inserting the HTML code into the database. When retrieving the HTML code from the database, you can use `htmlspecialchars_decode` function to decode any special characters back to their original form.

// Store HTML code in MySQL database
$html_code = "<h1>Hello, World!</h1>";
$escaped_html = mysqli_real_escape_string($conn, $html_code);
$sql = "INSERT INTO html_table (html_content) VALUES ('$escaped_html')";
mysqli_query($conn, $sql);

// Retrieve HTML code from MySQL database
$sql = "SELECT html_content FROM html_table WHERE id = 1";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$retrieved_html = htmlspecialchars_decode($row['html_content']);
echo $retrieved_html;