This topic is locked

Sending Emails after record updated

9/28/2009 4:52:07 PM
PHPRunner General questions
F
fawad112 author

Hi,
I need some help with sending emails to registered users in my database after a specific record is updated. and the emails will have few details after the record updated so basically it will have 2 different queries and will send the email also. I have this working code in my separate php file but i dont know how it will work in phprunner.
Please help.

$sql = "SELECT email FROM accounts ";
$result = mysql_query($sql) or die ('Error in query: $query. ' . mysql_error());
if (mysql_num_rows($result) > 0)

{
while($row = mysql_fetch_assoc($result))
{
$email = $row['email'];
$sql1 = "SELECT * FROM table where new = 5 and payment = 'Completed' ";
$result1 = mysql_query($sql1) or die ('Error in query: $query. ' . mysql_error());
if (mysql_num_rows($result1) > 0)

{
while($data = mysql_fetch_assoc($result1))
{

$ref=$data["ref"];
$subject = "Subject";

$subject4 = "Subject";

$message= "Check out the portal for more details\n" .

//"$ref" .

"Email Message ".
"\n\n------------------------------------------------------------\n" ;


mail($email, $subject, $message,"From: $email5\nReply-To: $email5");

mail($email11, $subject, $message,"From: $email5\nReply-To: $email5");
$sqlupdate = "UPDATE table set new = 4 where ref = '$ref' ";
$resultupdate = mysql_query($sqlupdate) or die ('Error in query: $query. ' . mysql_error());







}
}

}

}
else
{
echo "Error Mesage.!";
}
mysql_close($connection);


Regards

J
Jane 9/29/2009

Hi,
use After record updated event on the Events tab for this purpose.

F
fawad112 author 9/29/2009

Yes, I will use that event but can you tell me you should I convert this query to run in PHP runner.
Regards

J
Jane 9/30/2009

Hi,
you can use your code without changes in the event.