Re: [PHP-DB] Re: automactic email notification

2011-04-13 Thread Chris Stinemetz
On Wed, Apr 13, 2011 at 11:08 AM, Jim Giner
jim.gi...@albanyhandball.com wrote:
 Without looking at your HUGE code stream, I'm curious what your question
 really is.  If you know how to send an email, and you know how to update
 your table, then isn't your task simply to send an email after updating the
 table?

Yes.

 I would make the email a function to get it out of the way and
 then add a call to it right after I did an update.  The user probably gets a
 message of the successful update, so when you do that, that's when you call
 your email function.  Maybe have a couple of arguments in the function to
 pass some specifics and that's that.


Could you possbily show me an example? I am a newby when it comes to PHP.
Thank you!




 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: automactic email notification

2011-04-13 Thread Jim Giner
Looking at all that code you already wrote, you're not that much of a 
newbie.

Read up on functions.  (A function is merely the same code you already run 
but it's set aside, out of the main execution path of your script, so that 
you can call it from anyplace that you need to execute that particular set 
of code.)  Put the function's code near the top of your script.  Say you 
named your function SendAnEmail.  Call it when you need by typing a line 
that reads SendAnEmail();.

You might want to read up on arguments when learning about functions.  Then 
you could have a couple of them in your function that would allow you to 
pass specific info regarding the email you're sending, such as a timestamp 
for when the email was triggered, who triggered perhaps, what record key was 
changed.  Things like that.  Then you'd have a function header like:

function SendAnEmail($when,$who,$key)

and when you called the function you simply type

SendAnEmail($a,$b,$c) where $a is the datetime var you have for when it is, 
$b is the user who did it, and $c is the key that you updated.  In the 
function those would be represented by the var names you use in the function 
header and you can then put them in your email code where you want them to 
show up.  For ex., your email message might read like this:

At $when an update was performed by $who to the record with the key of 
$key.

That's enough to get you going - much more than I intended.

(rest deleted for brevity's sake :) ) 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php