How the McLuvin did you end up with a 700mb file with a database table with only 30 rows?
Anywho...
The following code will allow you to build an admin page where you can export individual tables into a file. You'll probibly want to modify the code to suit your needs, and add in data to your database to allow for a dynamic database restore section, but it's all up to you.
The code assumes you already have an active database connection and that you will be wrapping certain sections in conditions, e.g. isset($_POST) so that it doesn't execute every time the page loads.
You can use this to get a list of your database tables:
CODE
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<select name="sel_bak" id="sel_bak">
<?php
$sql = mysql_query('SHOW TABLES');
while($row = mysql_fetch_array($sql, MYSQL_ASSOC)){
echo '<option value="'.$row[$dbasename].'">'.$row[$dbasename].'</option>'."\n";
}
?>
</form>
Then this to get that tables data into a file:
CODE
<?php
mysql_query("SELECT * INTO OUTFILE 'mytablebackup.sql' FROM ".$_POST['sel_bak']);
?>
And just because I'm a nice guy, here's the code to 'restore' that information:
CODE
<?php
$dbTable = $_POST['sel_bak'];
mysql_query("LOAD DATA INFILE 'mytablebackup.sql' INTO TABLE $dbTable";
?>
Enjoy
This post has been edited by pemcconnell: 21 Aug, 2008 - 01:53 AM