Hello,
I have this while loop that is somewhat working I am trying to group the records by user and send one email with all related records for that user. I guess my logic is not working right. the first record per each user is missing, it’s not being output.
Thank you for your help
[php]
$msg = ‘’;
while($row = mysqli_fetch_array($q) ){
//$is = $row['is_id'];
if($is == '' || $is == $row['is_id']){
if($row['month'] == $month){
$template = 'Annual';
}
if($row['month'] == ($m2) ){
$template = 'Quarterly';
}
if($row['month'] == ($m3) ) {
$template = 'Semi-Annual';
}
if($row['month'] == ($m4) ) {
$template = 'Quarterly';
}
$teacher = $row['full_name'];
$msg .= $row['client_name'] . ' - ' . $row['full_name'] . ' - ' . $template . ' <a href="https://secure.iessi.net/docs.php?cid='.$row['case_no'].'">Click to Download</a> <br/>';
}
//$lastis = $row['is_id'];
if($is != $row['is_id']){
if(!empty($msg)){
echo 'Hello ' . $teacher . '<br/><br/>';
echo $msg . ' <br/> email sent <br/><br/><br/>';
}
$msg = '';
$is = $row['is_id'];
//$lastis = $row['is_id'];
}
}
[/php]