Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbhost = 'localhost:3036';
- $dbuser = 'root';
- $dbpass = 'rootpassword';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass);
- if(! $conn ) {
- die('Could not connect: ' . mysql_error());
- }
- $sql = 'SELECT q1, q2, FROM form';
- mysql_select_db('test_db');
- $retval = mysql_query( $sql, $conn );
- if(! $retval ) {
- die('Could not get data: ' . mysql_error());
- }
- $questions=array("$row['q1'],$row['q2']);
- $i = 0;
- while(i<2)) {
- if($questions[i] == "yes"){
- questions[i] = 1;
- }
- else
- if($questions[i] == "no"){
- questions[i] = 0
- }
- }
- echo "Fetched data successfully\n";
- $file = fopen("survey.csv","w");
- foreach ($list as $line)
- {
- fputcsv($file,explode(',',$line));
- }
- fclose($file);
- mysql_close($conn);
- $email = new PHPMailer();
- $email->From = 'you@example.com';
- $email->FromName = 'Your Name';
- $email->Subject = 'Message Subject';
- $email->Body = $bodytext;
- $email->AddAddress( 'destinationaddress@example.com' );
- $file_to_attach = FILE PATH OF SURVEY.CSV;
- $email->AddAttachment( $file_to_attach , 'survey.csv' );
- return $email->Send();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement