What is the syntax for altering a table name in MySQL using PHP?

When altering a table name in MySQL using PHP, you can use the "RENAME TABLE" statement. This statement allows you to change the name of a table in the database. You need to establish a connection to the MySQL database and then execute the SQL query to rename the table.

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database_name";

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

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

// SQL query to rename table
$sql = "RENAME TABLE old_table_name TO new_table_name";

if ($conn->query($sql) === TRUE) {
    echo "Table name changed successfully";
} else {
    echo "Error renaming table: " . $conn->error;
}

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