How can PHP be used to process and delete entries based on URL parameters?

To process and delete entries based on URL parameters in PHP, you can use the $_GET superglobal array to retrieve the parameter value from the URL and then use it to perform the deletion operation in your database. You can use a SQL query to delete the entry based on the parameter value passed in the URL.

<?php
// Check if the parameter is set in the URL
if(isset($_GET['id'])) {
    // Retrieve the parameter value from the URL
    $id = $_GET['id'];
    
    // Connect to your database
    $conn = new mysqli('localhost', 'username', 'password', 'database');
    
    // Check for connection errors
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    
    // Prepare and execute the SQL query to delete the entry based on the parameter value
    $sql = "DELETE FROM your_table WHERE id = $id";
    $result = $conn->query($sql);
    
    // Check if the deletion was successful
    if($result) {
        echo "Entry with ID $id deleted successfully.";
    } else {
        echo "Error deleting entry: " . $conn->error;
    }
    
    // Close the database connection
    $conn->close();
}
?>