<?php
error_reporting(0);
include 'config.php';
$sql=mysqli_query($con,'SHOW TABLES') or die(mysqli_error($con));
?>
<form action="" method="post">
<select name="pick">
<?php
while($res=mysqli_fetch_array($sql))
{?>
<option value="<?php echo $res[0]; ?>"><?php echo $res[0]; ?></option>
<?php
}
?>
</select>
<input type="submit" name="export" value="EXPORT">
<input type="file" name="choose" value="CHOOSE">
<input type="submit" name="import" value="EXPORT">
</form>
<?php
if(isset($_POST['export']))
{
$tableName = $_POST['pick'];
$backupFile = "www/".$_POST['pick'].".sql";
$query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";
$result = mysqli_query($con1,$query) or die(mysqli_error($con1));
if($result)
{
echo "<script>alert('Exported Successfully')</script>";
}
else
{
echo "<script>alert('Failed to Export')</script>";
}
}
?>
you cannot use an OUTFILE that already exists.
OK which way i need to use it
send me any other code sample
you must use a file that doesn’t exist yet.
You could append the filename with a timestamp. That would make it unique and it’s useful to know when a back up was created. Eg:-
$tableName = $_POST['pick'] . date(_Y-m-d_H-i-s) ;
i need to backup new data from a particular table
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.