Jump to content

SQL help


dannybrazil

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\" <[email protected]>\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

Archived

This topic is now archived and is 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.