MySQL TRUNCATE TABLE in PHP

<?php
$host="localhost"; 
$username="user";
$password="mysql_password";
$database="database_name";
$table="table_name";

$connection = mysql_connect("$host", "$username", "$password") or die ("Unable to connect to server");
mysql_select_db("$database") or die ("Unable to select database");
$sql = "TRUNCATE TABLE `$table`";
mysql_query($sql);
echo "Table Deleted";
mysql_close($connection);
?>


posted on 2017-04-16 16:47  ycfenxi  阅读(671)  评论(0编辑  收藏  举报