i want to backup table by table from databse mysql with php using mysqldump,,,,
my table show on list using checkbox.
if list of table checked all then my all table backup
if list of table one,two,three,etc checked the my table checked backup
this is my code:
<?php
include "config/conn.php";
echo "<h1>Database name: ".$db."</h1></br>";
echo "list of Tabel:";
$query = "SHOW TABLES";
$hasil = mysql_query($query);
echo "<form method='post' action='db/backupAction.php'>";
echo "<table>";
while ($data = mysql_fetch_row($hasil))
{
echo "<tr><td><input type='checkbox' name='tabel[]' value='".$data[0]."'></td><td>".$data[0]."</td></tr>";
}
echo "</table><br>";
echo "<input type='submit' name='submit' value='Backup Data' class='btn'>";
echo "</form>";
?>
and this is my file of backupAction.php
<?php
include "config/conn.php";
$tabel = $_POST['tabel'];
$listTabel = "";
foreach($tabel as $namatabel)
{
$listTabel = $namatabel ;
}
$command = "C:\xampp\Mysql\bin\mysqldump --user".$user." --password=".$pass." ".$db." ".$listTabel."\>".$db.".sql";
exec($command);
header("Content-Disposition: attachment; filename=".$db.".sql");
header("Content-type: application/download");
//$fp = fopen ($db.".sql", 'r');
//$content = fread($fp, filesize($db.".sql"));
//fclose($fp);
//echo $content;
//exit;
?>
my result file .sql is null
why???
$command? Does it work when you run it from the command line?"\>"seems invalid in your $command please echo it.