endrasgusti

Untitled

Nov 5th, 2017
548
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mysql_select_db($database_ska, $ska);
  2. $query_spc = "SELECT karyawan. nama, karyawan.email, kar_kegiatan.kegiatan
  3. FROM karyawan LEFT JOIN kar_kegiatan ON karyawan.nama=kar_kegiatan.nama ORDER BY nama";
  4. $spc = mysql_query($query_spc, $ska) or die(mysql_error());
  5. //$row_spc = mysql_fetch_assoc($spc);
  6. $totalRows_spc = mysql_num_rows($spc);
  7.  
  8. ?>
  9. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  10. <html xmlns="http://www.w3.org/1999/xhtml">
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  13. <title>Untitled Document</title>
  14. </head>
  15.  
  16. <body>
  17. <p>&nbsp;</p>
  18. <p>
  19. <?php
  20.  
  21. require '../phpmailer/class.phpmailer.php';
  22.  
  23. $mail = new PHPMailer(true);
  24.  
  25. $body .="<table border='1'>";
  26. $body .="<tr>";
  27.     $body .="<td>No</td>";
  28.     $body .="<td>nama</td>";
  29.     $body .="<td>email</td>";
  30.     $body .="<td>kegiatan</td>";
  31.  $body .="</tr>";
  32.  
  33. $i=1;
  34. $email='';
  35. while ($row_spc = mysql_fetch_assoc($spc)){
  36. if($email!=$row_spc['email']){ 
  37. $mail      = new PHPMailer(true);
  38.    $body .="<tr>";
  39.       $body .="<td>".$i."</td>";
  40.       $body .="<td>".$row_spc['nama']."</td>";
  41.       $body .="<td>".$row_spc['email']."</td>";
  42.       $body .="<td>".$row_spc['kegiatan']."</td>";
  43.      $body .="</tr>";
  44.      if($i!=1){
  45.         $email=$row_spc['email'];
  46.    $i++;
  47.   }
  48.   else {
  49.      $body .="<tr>";
  50.      $body .="<td></td>";
  51.      $body .="<td></td>";
  52.       $body .="<td></td>";
  53.       $body .="<td>".$row_spc['kegiatan']."</td>";
  54.      $body .="</tr>";
  55.   }
  56. }
  57.  
  58.     $body .="</table>";
  59.  
  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   = 'xxxxx@gmail.com';     // SMTP server username
  73.  
  74. $mail->Password   = 'xxxxxx';            // SMTP server password
  75.  
  76. //$mail->IsSendmail();  // tell the class to use Sendmail
  77.  
  78. $mail->AddReplyTo('xxxx@gmail.com');
  79.  
  80. $mail->From   = 'xxxx@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. </p>
  111. <p>&nbsp;</p>
  112.     <p>&nbsp;</p>
  113.     <p>&nbsp;</p>
  114.  
  115. </body>
  116. </html>
RAW Paste Data