Jump to content

MySQL TRUNCATE TABLE in PHP


nachotico

Recommended Posts

Just to help some fulks who don't know that and helping to grow the community

 

<?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);
?>

have a nice day...

Link to comment
https://forums.phpfreaks.com/topic/40468-mysql-truncate-table-in-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.