Jump to content

Recommended Posts

I have this sql:

 

Code:

$data = mysql_query("SELECT  * FROM remind WHERE event_date = cast(now() as date) ") or die(mysql_error());


	while($row = mysql_fetch_array($data))
	{	


	// ------ INFO FROM DATABASE FOR A SPECIFIC ENTRY -------- //
	$id=$row['id'];
	$day=$row['day'];
	$month=$row['month'];
	$email=$row['email'];
	$topic=$row['topic'];
	$text=$row['text'];

	// ======== check for DATE match - ONE DAY BEFORE =======// 



	   $message = 
                      "Hello,\n\n

                       We would like to remind you that tomorrow: \n
				   
				   $text
  
                           ___________________________________________________________________________________
  
                            ***                          PLEASE, DO NOT REPLY THIS MESSAGE                 ***
                           ___________________________________________________________________________________ ";

           mail($email , "Reminder", $message,
              "From: \"E-main Reminder\" <reminder@reminder.com>\r\n" .
               "X-Mailer: PHP/" . phpversion());







	}//enf od while loop

I have ONE entry with this DATE...BUT it keeps looping

 

It suppose to send only ONE e-mail isnt it ?

 

any help ?

Link to comment
https://forums.phpfreaks.com/topic/230030-sql-help/
Share on other sites

Because the mail() function is inside the while() loop, it will send one email for each result returned from the database. Also, rather than using date = CAST(NOW() AS DATE), you should be able to simply use date = CURDATE() . . .

Link to comment
https://forums.phpfreaks.com/topic/230030-sql-help/#findComment-1184748
Share on other sites

Thanks.

 

The thing is that I will have a table full of entries and I want that an EMAIL will be sent to each e-mail address on a specific date. And could be many entries on the same

date.

 

I was trying with ONLY one entry in the table, but it keeps looping. any way to send ONLY 1 e-mail to each e-mail address and then through it from the loop

Link to comment
https://forums.phpfreaks.com/topic/230030-sql-help/#findComment-1184867
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.