Hello,
I am hoping I can get some help here. What I am trying to do is send 1 email to a person and within that email display multiple records; kind of what the "List" page would display. I will not be using an event from the events page, but rather just a php script using DAL that will be sent out using the Task Schduler in Windows server. I have several php scripts that work great this way, but what I would like to add to these is a list of values from several lines in the database. The way it works now is sending an email for every record I am querying. The problem is 1 person could get 100 emails at one time. I want to send 1 email listing the 100 records. Here is what I have right now:
<?php
include("include/dbcommon.php");
//Send email 2 months before recert expiration.
global $dal;
$sql = "SELECT * FROM Table1 WHERE email_notification_number = '2' ";
$rs = CustomQuery($sql);
$data = db_fetch_array($rs);
$sql = "SELECT * FROM Table2 WHERE responsible_wl LIKE '%".$data['wl']."%' ";
$rs1 = CustomQuery($sql);
while($data1 = db_fetch_array($rs1))
{
// Date formats
$recertdate = $data['recert'];
$date1 = date("l, F d, Y",strtotime($recertdate));
//email
$email= $data1["email"];
$msg="";
$msg.="<html>
<head>
<title>My Title</title>
</head>
<body> <table width=\"800\" border=\"0\" cellspacing=\"0\" cellpadding=\"10\">
<tr>
<td>
<h2>Big Title Area.</h2>
<p>".$data1["name"].",</p>
<p> Some text. </p>
<p> Some more text.</p>
<p> Even More Text: </p>
<table border=\"0\" width=\"800\" cellspacing=\"10\" cellpadding=\"0\">
//***RESULTS WOULD GO HERE***
</table>
</td>
</tr>
</table>
</body>
</html> ";
$subject="My Subject.";
$from="email@email.com";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'htmlbody' => $msg, 'from'=>$from));
if(!$ret["mailed"])
{echo $ret["message"];}
}
?>
Right now this sends 1 email to each person from which the query gets data. I need to list the values from Table1, that being several fields per row of results.
Thanks for your help!
Brian