How to use PHP script to delete a data table:
Deleting a data table in MySQL is very easy to operate, but you can delete the table again Be very careful while doing this because all data will disappear after executing the delete command.
The following is the general syntax for deleting MySQL data tables:
DROP TABLE table_name ;
Use PHP script to delete data tables
PHP uses the mysqli_query function to delete MySQL data tables.
This function has two parameters and returns TRUE when executed successfully, otherwise it returns FALSE.
Grammar
mysqli_query(connection,query,resultmode);
<?php $dbhost = 'localhost:3306'; // mysql服务器主机地址 $dbuser = 'root'; // mysql用户名 $dbpass = '123456'; // mysql用户名密码 $conn = mysqli_connect($dbhost, $dbuser, $dbpass); if(! $conn ){ die('连接失败: ' . mysqli_error($conn));} echo '连接成功<br />'; $sql = "DROP TABLE runoob_tbl"; mysqli_select_db( $conn, 'RUNOOB' ); $retval = mysqli_query( $conn, $sql ); if(! $retval ){ die('数据表删除失败: ' . mysqli_error($conn));} echo "数据表删除成功\n";mysqli_close($conn);?>
Related references:php中文网
The above is the detailed content of How to delete data table using PHP script. For more information, please follow other related articles on the PHP Chinese website!