How can PHP be used to retrieve and display specific meta tag information from a database based on the URL of a content page?

To retrieve and display specific meta tag information from a database based on the URL of a content page, you can create a PHP script that takes the URL as a parameter, queries the database for the corresponding meta tags, and then displays them on the page.

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

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

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

// Get URL parameter
$url = $_GET['url'];

// Query database for meta tags based on URL
$sql = "SELECT * FROM meta_tags WHERE url = '$url'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Output meta tags
    while($row = $result->fetch_assoc()) {
        echo "<meta name='" . $row["name"] . "' content='" . $row["content"] . "'>";
    }
} else {
    echo "No meta tags found for this URL";
}

$conn->close();
?>