http://reeteshghimire.com.np/2019/07/04/backup-restore-mysql-database-using-php/ https://stackoverflow.com/questions/22195493/export-mysql-database-using-php-only <?php $connection = mysqli_connect ( 'localhost' , 'root' , '' , 'quiz' ) ; $tables = array ( ) ; $result = mysqli_query ( $connection, "SHOW TABLES" ) ; while ( $row = mysqli_fetch_row ( $result ) ) { $tables [ ] = $row [ 0 ] ; } $return = '' ; foreach ( $tables as $table ) { $result = mysqli_query ( $connection, "SELECT * FROM " .$table ) ; $num_fields = mysqli_num_fields ( $result ) ; $return .= 'DROP TABLE ' .$table. ';' ; $row2 = mysqli_fetch_row ( mysqli_query ( $connection, "SHOW CREATE TABLE " .$table ) ) ; $return .= "\n\n" .$row2 [ 1 ] . ";\n\n" ; for ( $i= 0 ;$i<$num_fields;$i++ ) { while ( $row = mysqli_fetch_row ( $result ) ) { $return .= "I...
Comments
Post a Comment