Location: PHPKode > projects > DDL CMS > Upload these files to your webspace/admin/optimtables.inc
<h2>Optimizing Tables</h2>
<p>Checking and optimizing database tables...</p>
<p>
<?php
		echo 'Database:  ' . MYSQLDB . '<br><br>';
		$res = dbcom("SHOW TABLE STATUS FROM `" . MYSQLDB . "`");
		$to_optimize = array();
		while($rec = mysql_fetch_array($res))
		{
			echo 'Table: ' . $rec['Name'] . ' ';
			if($rec['Data_free'] > 0)
			{
				$to_optimize [] = $rec['Name'];
				echo '... needs optimizing.<br>';
			}
			else
			{
				echo '... Ok.<br>';
			}
		}
		if(count($to_optimize) > 0)
		{
			foreach($to_optimize as $tbl)
			{
				dbcom("OPTIMIZE TABLE `" . $tbl ."`");
			}
			echo '<p>Done optimizing!</p>';
		}
		else
		{
			echo '<p>Nothing needs optimizing!</p>';
		}
?>
</p>
Return current item: DDL CMS