stivenbr Posted October 8, 2014 Share Posted October 8, 2014 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. somewhere in my logic is not working right. the first record per each user is missing in my code. Thank you for your help $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']; } } Link to comment https://forums.phpfreaks.com/topic/291509-while-loop-help/ Share on other sites More sharing options...
Barand Posted October 8, 2014 Share Posted October 8, 2014 (edited) You have already posted this question. Don't double post. http://forums.phpfreaks.com/topic/291491-query-help-grouping/?do=findComment&comment=1492979 Edited October 8, 2014 by Barand Link to comment https://forums.phpfreaks.com/topic/291509-while-loop-help/#findComment-1493045 Share on other sites More sharing options...
Recommended Posts