imath

export snippets to txt file

Nov 30th, 2012
38
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. define('DB_NAME', 'bp_code_snippets');
  4.  
  5. /** Utilisateur de la base de données MySQL. */
  6. define('DB_USER', 'root');
  7.  
  8. /** Mot de passe de la base de données MySQL. */
  9. define('DB_PASSWORD', 'root');
  10.  
  11. /** Adresse de l'hébergement MySQL. */
  12. define('DB_HOST', 'localhost');
  13.  
  14. $connect = mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
  15. mysql_select_db( DB_NAME );
  16.  
  17. $sql = mysql_query( "SELECT * FROM wp_code_snippets", $connect);
  18. $csv = '';
  19.  
  20. while ( $results = mysql_fetch_object( $sql ) ) {
  21.     $csv .= stripslashes( html_entity_decode( $results->snippet_content, ENT_QUOTES ) ) ."\n\n";
  22. }
  23.  
  24. header("content-type: text/csv; charset=utf-8" );
  25. header('Content-Disposition: attachement; filename="export.csv"');
  26. echo $csv;
  27. ?>
RAW Paste Data