How can you delete the content of a specific column in a row in a MySQL database using PHP?

To delete the content of a specific column in a row in a MySQL database using PHP, you can execute an SQL query that updates the column with an empty value. You can achieve this by using the UPDATE statement in MySQL along with PHP's mysqli extension to connect to the database and execute the query.

<?php
// Connect to the database
$mysqli = new mysqli("localhost", "username", "password", "database");

// Check connection
if($mysqli === false){
    die("ERROR: Could not connect. " . $mysqli->connect_error);
}

// Define the column and row to update
$column = "column_name";
$row_id = 1;

// Update the column with an empty value
$sql = "UPDATE table_name SET $column = '' WHERE id = $row_id";

if($mysqli->query($sql) === true){
    echo "Column content deleted successfully.";
} else{
    echo "ERROR: Could not execute $sql. " . $mysqli->error;
}

// Close connection
$mysqli->close();
?>