Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retrieve more than one data in email?
    text
    copied!<p>I have a table named 'laptop' and a column inside the table named 'Lap_War_Expiry'. I need to send an email to user when the warranty of the laptop is going to expire soon. For your information, there is more than one warranty that will expired in a day. But the code below is only send the same data from table 'laptop'. Why is that happened and what I have to add in the code so that the email send will retrieve two or more data from database ?</p> <p>This is my coding for sending the email : </p> <pre><code>&lt;?php require 'class.phpmailer.php'; $mail = new PHPMailer(); $mail-&gt;IsSMTP(); $mail-&gt;Mailer = 'smtp'; $mail-&gt;SMTPAuth = true; $mail-&gt;Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked $mail-&gt;Port = 465; $mail-&gt;SMTPSecure = 'ssl'; // ======== get database data ================== $link = mysql_connect("localhost","root",""); $database="master_inventory"; mysql_select_db ($database,$link) OR die ("Could not open $database" ); $query = 'SELECT Lap_PC_Name, Lap_War_Expiry FROM laptop'; //xyz is id of desired user name. $result1 = mysql_query($query); while($row = mysql_fetch_array($result1)) { $Lap_PC_Name = $row['Lap_PC_Name']; $Lap_War_Expiry = $row['Lap_War_Expiry']; } $mail-&gt;Username = "email@gmail.com"; $mail-&gt;Password = "somepassword"; $mail-&gt;IsHTML(true); // if you are going to send HTML formatted emails $mail-&gt;SingleTo = true; $mail-&gt;From = "email@gmail.com"; $mail-&gt;FromName = "AMS"; $mail-&gt;addAddress("emailaddress","AMS"); $mail-&gt;Subject = "Notification on warranty expiry"; $mail-&gt;Body = "Dear Madam,&lt;br/&gt;&lt;br /&gt;The licensed for the following PC will expired in less than one month.&lt;br /&gt;&lt;br /&gt; PC Name : ".$Lap_PC_Name. "&lt;br /&gt;Date of expired :" .$Lap_War_Expiry; if(!$mail-&gt;Send()) echo "Message was not sent &lt;br /&gt;PHPMailer Error: " . $mail-&gt;ErrorInfo; else echo "Message has been sent"; ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload