I have created a php file for cron job. I want To send Lecture details To Users Through this cron job. The code is as follows :
<?
$login=mysql_query("select * from table1 WHERE member_status = '1' AND email_lecture_sent ='0' ");
$datelogin=mysql_fetch_array($login);
$current_date=date("Y-m-d H:i:s a");
$objTotalRS=mysql_query("select * from table2 where display_time >'".$current_date."' order by lecture_start asc limit 0,1");
while ($data=mysql_fetch_array($objTotalRS)) {
$date1= date("Y-m-d");
$date2=date("Y-m-d",strtotime($data['lecture_start']));
$dateDiff = strtotime($date2) - strtotime($date1);
$fullDays = floor($dateDiff/(60*60*24));
if($datelogin['email_lecture_sent'] = '0'){
mysql_query(" UPDATE table1 SET email_lecture_sent = '1' WHERE reg_id =".$datelogin['reg_id']);
}
if($fullDays=="1" || $fullDays=="2"){
ob_start();
?>
email content containing lecture details along with user's data like username, password etc.. .
<?
$body=ob_get_contents();
ob_end_clean ();
$to = $datelogin["email"];
$sub = "Our Next Live Session";
$mail->IsHTML(true);
$mail->Host = "mail.abc.com";
$mail->From = "info@abc.com";
$mail->FromName = "ABC";
$mail->AddAddress($to);
$mail->Subject = $sub;
$mail->Body = $body;
$mail->WordWrap = 50;
if($mail->Send()){
echo"Success...";
}else{
echo"oops";
}
$mail->ClearAddresses();
$mail->ClearCCs();
$mail->ClearBCCs();
}
}
?>
BUT problem is when I run this file, it sends only one email in one cron job and not to all with member_status='1' and email_lecture_sent='0'