I am trying to work with a script written by a previous developer that empties a number of different tables. The problem now is that I have added a table called 'order' and breaks the loop.
set_time_limit (0);
$conn = mysql_connect('localhost', 'root', '') or die ('Error connecting to mysql');
mysql_select_db('database-name');
$tables = array(
'address',
'manufacturer',
'order',
'voucher_history',
'voucher_theme',
);
foreach ($tables as $table) {
$sql = sprintf('TRUNCATE TABLE %s', $table);
printf('%s %s ', $sql, str_repeat('.', 73 - strlen($sql)));
$result = mysql_query($sql);
if (!$result) {
die('Invalid query: ' . mysql_error());
}else {
echo "Done!<br />";
}
}