I have a bit of code I'm using to generate a report from my MySQL database - what I want to do is email it out to multiple recipients (whose email addresses are also stored in the database).
The email addresses (up to 12 of them) are located in fields s1e - s12e. What I want to do is check these fields and only send emails if the seat is filled (field is populated) and preferable, if the seat status is not yet confirmed.
I have tried both getting all the recipients at once:
//Get recipients from CourseQuery
$recipient1 = $row["s1e"];
$recipient2 = $row["s2e"];
$recipient3 = $row["s3e"];
$recipient4 = $row["s4e"];
$recipient5 = $row["s5e"];
$recipient6 = $row["s6e"];
$recipient7 = $row["s7e"];
$recipient8 = $row["s8e"];
$recipient9 = $row["s9e"];
$recipient10 = $row["s10e"];
$recipient11 = $row["s11e"];
$recipient12 = $row["s12e"];
or doing if statements to check for the seats being filled:
//Get sign ups for course 1
$courseQuery = 'SELECT s1e,s2e,s3e FROM class WHERE CID = "'.$cid.'"';
//Execute query and get resultSet
$result = mysql_query($courseQuery );
//Loop through sign ups and generate email report to each candidate (using code from report.php)
$i=1;
while($row = mysql_fetch_array($result))
{
if ($s1i <> "" and $s1s <> "confirmed")
{
$recipient1 = $row["s1e"];
}
elseif ($s2i <> "" and $s2s <> "confirmed")
{
$recipient2 = $row["s2e"];
}
elseif ($s3i <> "" and $s3s <> "confirmed")
{
$recipient3 = $row["s3e"];
}
else
{
echo "no match";
}
Nothing I have tried has worked yet. Any help would be appreciated.