Advertisement
Guest User

Untitled

a guest
Feb 11th, 2017
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <?php
  2. $dbhost = 'localhost:3036';
  3. $dbuser = 'root';
  4. $dbpass = 'rootpassword';
  5.  
  6. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  7.  
  8. if(! $conn ) {
  9. die('Could not connect: ' . mysql_error());
  10. }
  11.  
  12. $sql = 'SELECT q1, q2, FROM form';
  13. mysql_select_db('test_db');
  14. $retval = mysql_query( $sql, $conn );
  15.  
  16. if(! $retval ) {
  17. die('Could not get data: ' . mysql_error());
  18. }
  19.  
  20. $questions=array("$row['q1'],$row['q2']);
  21. $i = 0;
  22. while(i<2)) {
  23. if($questions[i] == "yes"){
  24. questions[i] = 1;
  25. }
  26. else
  27. if($questions[i] == "no"){
  28. questions[i] = 0
  29. }
  30. }
  31.  
  32. echo "Fetched data successfully\n";
  33.  
  34. $file = fopen("survey.csv","w");
  35.  
  36. foreach ($list as $line)
  37. {
  38. fputcsv($file,explode(',',$line));
  39. }
  40.  
  41. fclose($file);
  42.  
  43. mysql_close($conn);
  44.  
  45. $email = new PHPMailer();
  46.  
  47. $email->From = 'you@example.com';
  48. $email->FromName = 'Your Name';
  49. $email->Subject = 'Message Subject';
  50. $email->Body = $bodytext;
  51. $email->AddAddress( 'destinationaddress@example.com' );
  52.  
  53. $file_to_attach = FILE PATH OF SURVEY.CSV;
  54.  
  55. $email->AddAttachment( $file_to_attach , 'survey.csv' );
  56.  
  57. return $email->Send();
  58.  
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement