Thank you very much that was it!! 🙂
I had to add another portion to the code and it was to check more records. I hope I can explain, it could be a bit confusing. I had to get all records from the query and filter on the loop instead of filter in the query because I needed different criteria that I wasn't able to in the SQL. So I was able to do both filters and show them the problem is that that is not grouping by Infant Specialist the second filter is giving me all the records. Here is my code and I'm going to show a screen shot of the result.
while($row = mysqli_fetch_array($q) ){
if($lastis != $row['is_id']){
if(!empty($msg)){
$body = 'Hello ' . $teacher . '<br/><br/> Here is the list of reports due by ' . date('F') . ' 15th. <br/><br/>';
$table = '<table align="left" cellspacing="2" cellpadding="2" width="750" border="1px dashed black">
<tr>
<th align="center" width="35%"><b>Client Name</b></th>
<th align="center" width="10%"><b>DOB</b></th>
<th align="center" width="15%"><b>Template</b></th>
<th align="center" width="10%"><b>Due Date</b></th>
<th align="center" width="30%"><b>Link</b></th>
</tr>';
$endtable = '</table><div style="clear:both"></div>';
$body .= $table . $msg . $closing . $endtable . ' <br/><br/> Thank you,<br/>company, Inc<br/><br/>';
//if($is == 19){
//$ret=runner_mail(array('to' => $to, 'subject' => $subject, 'htmlbody' => $body, 'from'=>$from));
echo $body;
//}
}
$msg = '';
}
/////////// IFSP REPORTS //////////////////
if($row['month'] == $month || $row['month'] == $m2 || $row['month'] == $m3 || $row['month'] == $m4){
if($row['month'] == $month){
$template = 'Annual';
//if($row['DOB']
$tem = 'a';
}
if($row['month'] == ($m2) ){
$template = 'Quarterly';
$tem = 'q';
}
if($row['month'] == ($m3) ) {
$template = 'Semi-Annual';
$tem = 'sa';
}
if($row['month'] == ($m4) ) {
$template = 'Quarterly';
$tem = 'q';
}
$teacher = $row['full_name'];
$is_email = $row['is_email'];
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');
$msg .= '<tr bgcolor="' . $bg . '">
<td align="left">' . $row['client_name'] . '</td>
<td align="left" style="text-align:center">' . format_date($row['DOB']) . '</td>
<td align="left" style="text-align:center">' . $template . '</td>
<td align="left" style="text-align:center">' . date('m/').'15/'.date('y') . '</td>
<td align="left" style="text-align:center"><a href="https://domain.com/docs.php?cid='.$row['case_no'].'&temp='.$tem.'&rdate='.$r_date.'">Click to Download</a></td>
</tr>';
}
//////// CLOSING REPORTS ////////////
$dob = strtotime($row['DOB']);
$fyear = $year - 3;
$start_date = strtotime($fyear . '-' . $month . '-01');
$mday = date('t',$start_date);
$end_date = strtotime($fyear . '-' . $month . '-' . $mday);
if( ($dob >= $start_date) && ($dob <= $end_date) ){
$cdate = strtotime('+3 years', strtotime($row['DOB']));
$closed_date = date('m/d/y',$cdate);
$template = 'Closing';
$tem = 'c';
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');
$closing .= '<tr bgcolor="' . $bg . '">
<td align="left">' . $row['client_name'] . '</td>
<td align="left">' . format_date($row['DOB']) . '</td>
<td align="left" style="text-align:center">' . $template . '</td>
<td align="left" style="text-align:center">' . $closed_date . '</td>
<td align="left" style="text-align:center"><a href="https://domain.com/docs.php?cid='.$row['case_no'].'&temp='.$tem.'&rdate='.$r_date.'">Click to Download</a></td>
</tr>';
$count++;
}
$is = $row['is_id'];
$lastis = $row['is_id'];//
}
echo $count;
$body = 'Hello ' . $teacher . '<br/><br/> Here is the list of reports due by ' . date('F') . ' 15th. <br/><br/>';
$table = '<table align="left" cellspacing="2" cellpadding="2" width="600 border="1px dashed black">
<tr>
<th align="center" width="45%"><b>Client Name</b></th>
<th align="center" width="30%"><b>Template</b></th>
<th align="center" width="25%"><b>Link</b></th>
</tr>';
$endtable = '</table><div style="clear:both"></div>';
$body .= $table . $msg . $endtable . ' <br/><br/> Thank you,<br/>Company, Inc<br/><br/>';
[ATTACH]5159[/ATTACH]
sample.jpg