Jump to content

Recommended Posts

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

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.