This topic is locked

sending email to person for job assignment

5/11/2008 6:12:54 PM
PHPRunner General questions
W
wfcentral author

I have two tables...
tbl_users

user_ID | name | email
tbl_job

job_ID | title | assigned_to
I'm trying to make it so that after I update a job and assign it to "Joe" it will send him an email.
Things to consider...
tbl_job assigned_to is a number that represents tbl_users user_ID (so, the event needs to lookup the email address in the tbl_users where the user_ID matches tbl_job assigned_to
the other catch is that sometimes I update the title on the job and I don't need "Joe" getting an email unless that field (assigned_to) just changed.
I've tried a bunch of stuff and I'm not having any luck...
Robert

W
wfcentral author 5/11/2008

okay - I got the email working now, I just need to make it so it ONLY SENDS EMAIL when the field "assigned_to" has changed...
Robert
global $conn;

//select email address from User table for person who just got job assigned

$str = "select email from tbl_USERS where user_ID = ".$values["assigned_to"];

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
$str2 = "select name from tbl_USERS where user_ID = ".$values["user_ID"];

$rs2 = db_query($str2,$conn);

$data2 = db_fetch_array($rs2);
// ** Send data email ****

$email=$data["email"];

$message="This email is a notification that someone has transferred \r\n";

$message.="an job to your dashboard .\r\n\n";

$message.="Ratee: ".$data2["name"]."\r\n\n";

$subject="a job has just been added to your dashboard.";

J
Jane 5/12/2008

Hi,
here is a sample:

if ($values["assigned_to"]==$oldvalues["assigned_to"])

{

...

}