document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. function jsa_export_func()
  2. {
  3. $filename = home_url . "\\wp-content\\plugins\\jsa-database\\csv\\JSA-Download.csv";
  4. $fh = fopen( $filename, 'w' ) or die("Can't open file");
  5.  
  6. global $wpdb;
  7.  
  8. $results = $wpdb->get_results( $wpdb->prepare("SELECT ID, name, postdate, posttitle, location
  9. FROM wp_jsadb;", ARRAY_A ) );
  10. $headerDisplayed = false;
  11. foreach ( $results as $data ) {
  12. if ( !$headerDisplayed ) {
  13. fputcsv($fh, array_keys($data));
  14. $headerDisplayed = true;
  15. }
  16. fputcsv($fh, $data);
  17. }
  18. fclose($fh);
  19. exit();
  20.  
  21. echo '<br/>' . "Right click and Save Target As: " . '<a href=" ' . $filename . ' " target="_blank">[DOWNLOAD CSV]</a>';
  22. }
  23.  
  24.  
');