/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
backup_tables('localhost','username','password','blog'); /* backup the db OR just a table */ function backup_tables($host,$user,$pass,$name,$tables = '*') { //get all of the tables if($tables == '*') { { $tables[] = $row[0]; } } else { } //cycle through foreach($tables as $table) { for ($i = 0; $i < $num_fields; $i++) { $return.= 'DROP TABLE '.$table.';'; $return.= "\n\n".$row2[1].";\n\n"; { $return.= 'INSERT INTO '.$table.' VALUES('; for($j=0; $j<$num_fields; $j++) { if ($j<($num_fields-1)) { $return.= ','; } } $return.= ");\n"; } } $return.="\n\n\n"; } //save file }