Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php
  2. $host = 'mysql021.phy.lolipop.lan';
  3. $user = 'LAA0558236';
  4. $pass = 'HGRd0N1y';
  5. $db = 'LAA0558236-c9bax4';
  6. $table = 'wp1_usermeta';
  7. $file = 'export';
  8.  
  9. $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
  10. mysql_select_db($db) or die("Can not connect.");
  11.  
  12. $result = mysql_query("SELECT * FROM ".$table." WHERE NOT user_id = 1 ");
  13. $i = 0;
  14. if (mysql_num_rows($result) > 0) {
  15. while ($row = mysql_fetch_assoc($result)) {
  16. $csv_output .= "User ID"."\t";
  17. $csv_output .= "Name"."\t";
  18. $csv_output .= "Date of Birth"."\t";
  19. $csv_output .= "Address"."\t";
  20. $csv_output .= "Email"."\t";
  21. $csv_output .= "Annual Income"."\t";
  22. $csv_output .= "Doctor ID"."\t";
  23. $csv_output .= "Reg. No"."\t";
  24. $csv_output .= "Username"."\t";
  25. $csv_output .= "Password"."\t";
  26. $i++;
  27. }
  28. }
  29. $csv_output .= "\n";
  30.  
  31. $values = mysql_query("SELECT * FROM ".$table."");
  32. while ($rowr = mysql_fetch_row($values)) {
  33. for ($j=0;$j<$i;$j++) {
  34. $csv_output .= $rowr[$j]." ";
  35. }
  36. $csv_output .= "\n";
  37. }
  38.  
  39. $filename = $file."_".date("Y-m-d_H-i",time());
  40. header("Content-type: application/vnd.ms-excel");
  41. header("Content-disposition: csv" . date("Y-m-d") . ".csv");
  42. header( "Content-disposition: filename=".$filename.".csv");
  43. print $csv_output;
  44. exit;
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement