endrasgusti

Untitled

Nov 5th, 2017
395
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. mysql_select_db($database_ska, $ska);
  3. $query_spc = "SELECT karyawan. nama, karyawan.email, kar_kegiatan.kegiatan
  4. FROM karyawan LEFT JOIN kar_kegiatan ON karyawan.nama=kar_kegiatan.nama ORDER BY nama";
  5. $spc = mysql_query($query_spc, $ska) or die(mysql_error());
  6. //$row_spc = mysql_fetch_assoc($spc);
  7. $totalRows_spc = mysql_num_rows($spc);
  8.  
  9. ?>
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  11. <html xmlns="http://www.w3.org/1999/xhtml">
  12. <head>
  13. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  14. <title>Untitled Document</title>
  15. </head>
  16.  
  17. <body>
  18. <p>&nbsp;</p>
  19. <p>
  20. <?php
  21.  
  22. require '../phpmailer/class.phpmailer.php';
  23.  
  24. $mail = new PHPMailer(true);
  25.  
  26. $i=1;
  27. $email='';
  28. while ($row_spc = mysql_fetch_assoc($spc)){
  29. if($email!=$row_spc['email']){ 
  30. $mail      = new PHPMailer(true);
  31. $body      =  "<html>
  32.               <head>
  33.                </head>
  34.  
  35. <body>
  36.    echo '<tr>
  37.      <td>".$i."</td>
  38.      <td>".$row_spc['nama']."</td>
  39.      <td>".$row_spc['email']."</td>
  40.      <td>".$row_spc['kegiatan']."</td>
  41.      </tr>';
  42.      if($i!=1){
  43.      $email=".$row_spc['email'].";
  44.   $i++;
  45.  }
  46.  else {
  47.       echo '<tr>
  48.      <td></td>
  49.      <td></td>
  50.      <td></td>
  51.      <td>".$row_spc['kegiatan']."</td>
  52.      </tr>';
  53.  }
  54. }
  55.  ?>
  56.    </table>
  57.  
  58.    </body>
  59.    </html>";
  60.  
  61.    
  62. $mail->IsSMTP();                           // tell the class to use SMTP
  63.  
  64. $mail->SMTPAuth   = true;                  // enable SMTP authentication
  65.  
  66. $mail->SMTPSecure = 'tls';
  67.  
  68. $mail->Port  = 587;                    // set the SMTP server port
  69.  
  70. $mail->Host  = 'smtp.gmail.com'; // SMTP server
  71.  
  72. $mail->Username   = 'phpprathama@gmail.com';     // SMTP server username
  73.  
  74. $mail->Password   = 'prathama0109';            // SMTP server password
  75.  
  76. //$mail->IsSendmail();  // tell the class to use Sendmail
  77.  
  78. $mail->AddReplyTo('phpprathama@gmail.com');
  79.  
  80. $mail->From   = 'phpprathama@gmail.com';
  81.  
  82. $mail->FromName   ='xxxxx';
  83.  
  84. $to = $row_spc['email'];
  85.  
  86. $mail->AddAddress($to);
  87.  
  88. $mail->Subject  = 'report sales';
  89.  
  90. //$mail->AltBody    = “To view the message, please use an HTML compatible email viewer!”;
  91.  
  92. // optional, comment out and test
  93.  
  94. //$mail->WordWrap   = 80; // set word wrap
  95.  
  96. $mail->MsgHTML($body);
  97.  
  98. $mail->IsHTML(true); // send as HTML
  99.  
  100. $mail->Send();
  101.  
  102. echo 'Message has been sent.';
  103.  
  104.  
  105. $i++;
  106. }
  107. }
  108.  
  109.  
  110. ?>
  111. </p>
  112. <p>&nbsp;</p>
RAW Paste Data