What is the purpose of using the ALTER command in PHP?
The ALTER command in PHP is used to modify an existing database table by adding, removing, or modifying columns. This command is useful when you need to make changes to the structure of your database without having to recreate the entire table.
// Example of using the ALTER command to add a new column to an existing table
$sql = "ALTER TABLE users ADD COLUMN email VARCHAR(255) NOT NULL";
$result = mysqli_query($conn, $sql);
if($result) {
echo "Column added successfully";
} else {
echo "Error adding column: " . mysqli_error($conn);
}