/ Published in: PHP
                    
                                        The script below connects to a MySQL database server on "localhost" using the login name "test" and password "123456" and then connects to the database "test". It then copies the table structure and data from the table "products" to a new table "products_bak". If the target table already exists the function returns false.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 <?php if(copy_table('products', 'products_bak')) { echo "success\n"; } else { echo "failure\n"; } function copy_table($from, $to) { if(table_exists($to)) { $success = false; } else { $success = true; } return $success; } function table_exists($tablename, $database = false) { if(!$database) { } SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_schema = '$database' AND table_name = '$tablename' "); } ?>
URL: http://www.electrictoolbox.com/php-script-backup-copy-mysql-table/
Comments
                    Subscribe to comments
                
                