This topic is locked

How To Generate An Event For Specific Fields

12/29/2006 1:30:51 PM
PHPRunner General questions
T
tdh author

Wow! The demo works great! This is exactly what I was looking for. New customer on the way!!!

Here's the scenario:

Basically I have created a table to hold student scores from these three fields - Math, Reading, Science.
When score data is entered in any one of these fields that has a value of say 59 or below, I would like to create an event that would email someone.
How I can achieve this?
Thank you for your patience, I'm not a "from scratch" programmer.
Have a good day and Happy New Year!

Sergey Kornilov admin 12/29/2006

You can try something like this.

function BeforeAdd(&$values)

{
if ($values["Math"]<59 || $values["Reading"]<59 || $values["Science"]<59 )

{
$email="test@test.com";

$message="Hello there\nBest regards";

$subject="Sample subject";

mail($email, $subject, $message);
}
return true;
// return true if you like to proceed with adding new record

// return false in other case
}


If you are interested in getting a New Year discount contact me directly at support@xlinesoft.com

T
tdh author 1/3/2007

Hello again,
Sorry about the double posting.

In reference to Post #1 on this topic:

The code worked great for this. Thank you again. How do I specify a particular field and it's value in the email that is sent?
For example, if a score of 58 was entered in the Reading field, how would I include Reading:58in the email?
Thank you for your time and reply.
When I purchase the license, I would like to integrate JPGraph into this. I haven't played around with JPGraph yet, but would it be safe to say I could generate graphs from search results in the database?

I read somewhere in the forum graphing was going to be included in the summer upgrade?
I've looked at alot of PHP generation software and I've got to say the demo for PHPRunner so far has impressed me to the point of purchase. Good job xlinesoft.com ! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=14226&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />

Sergey Kornilov admin 1/3/2007

See code example that includes the value of Reading scores into email if Reading score equals 58.
if ( $values["Reading"]==58 )

{
$email="test@test.com";

$message="Reading:" . $values["Reading"];

$subject="Sample subject";

mail($email, $subject, $message);
}
Regarding graphs - it's easy to plugin JPGraph or similar solution. Basically you just need to provide a set of data to graphing routine and it takes care of evertything.
As I mentioned ealier you need to contact me directly at support@xlinesoft.com in regards of purchase questions.

T
tdh author 1/3/2007

Thanks Sergey. I am putting together a demo to show my boss what this can do for our school system. Hope to be done before trial expires. That gives me a good target date for approval and purchase.

T
tdh author 1/3/2007

On the line below:

$message="Reading:" . $values["Reading"] ;
This works good for the Reading, but if I wanted to output the email like this for instance:
Reading:50

Math:50

Science:50
How could I accomplish this?
Thank You <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=14257&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />

See code example that includes the value of Reading scores into email if Reading score equals 58.

if ( $values["Reading"]==58 )

{
$email="test@test.com";

$message="Reading:" . $values["Reading"];

$subject="Sample subject";

mail($email, $subject, $message);
}
Regarding graphs - it's easy to plugin JPGraph or similar solution. Basically you just need to provide a set of data to graphing routine and it takes care of evertything.
As I mentioned ealier you need to contact me directly at support@xlinesoft.com in regards of purchase questions.

L
larsonsc 1/3/2007

On the line below:

$message="Reading:" . $values["Reading"] ;
This works good for the Reading, but if I wanted to output the email like this for instance:
Reading:50

Math:50

Science:50
How could I accomplish this?
Thank You <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=14260&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />


Keep adding as many $message= lines as you need. I Think to have multiples, it would look something like this:

if ( $values["Reading"]==58 )

{
$email="test@test.com";

$message="Reading:" . $values["Reading"]."\n";

$message.="Math: " . $values["Math"]."\n";

$subject="Sample subject";

mail($email, $subject, $message);
}


The \n is a new line so I think that should take care of what you need. Make sure you have .= in each additional $message line so that they concatenate properly. Let me know if you need any other help and I'll see if I can find one of my old email form processor scripts that did a similar thing.
--Shawn

T
tdh author 1/4/2007

Thanks Shawn for the reply. I tried using the synthax you posted, but it only output the last one.



Keep adding as many $message= lines as you need. I Think to have multiples, it would look something like this:

if ( $values["Reading"]==58 )

{
$email="test@test.com";

$message="Reading:" . $values["Reading"]."\n";

$message.="Math: " . $values["Math"]."\n";

$subject="Sample subject";

mail($email, $subject, $message);
}


The \n is a new line so I think that should take care of what you need. Make sure you have .= in each additional $message line so that they concatenate properly. Let me know if you need any other help and I'll see if I can find one of my old email form processor scripts that did a similar thing.
--Shawn

L
larsonsc 1/4/2007

Oh, sorry...I didn't pay attention to the $values parameter being passed to the if statement. The support team might have to give you some better code, but I think this should be pretty close to what you need. This would generate an email for any test score entered into any of the three fields with a value less than 60. You could of course customize the values to whatever you need.

if (($values["Reading"] < 60) || ($values["Math"] < 60) || ($values["Science"] < 60)) {
$email = "email@email.com";

$subject = "Your Student's Recent Test Score(s)";

$message = "We would like to inform you of your child's latest test scores." . "\n\n";

$message .= "Reading: " . $values["Reading"] . "\n";

$message .= "Math: " . $values["Math"] . "\n";

$message .= "Science: " . $values["Science"] . "\n\n\n";

$message .= "Please feel free to contact your child's instructor if you feel you need to discuss your child's performance.";
mail($email, $subject, $message);
}


Let me know if I can be of any further assistance. Hopefully that will work for you though and I won't have to give you any more bad code. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=14279&image=1&table=forumreplies' class='bbc_emoticon' alt=':P' />

T
tdh author 1/5/2007

Thanks Shawn!

This worked great. From this, I can now output any field and it's value from MYSQL straight to an email. I'm definately sold on this product and will be purchasing it when the demo runs out!
Have a good one <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=14283&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />

Oh, sorry...I didn't pay attention to the $values parameter being passed to the if statement. The support team might have to give you some better code, but I think this should be pretty close to what you need. This would generate an email for any test score entered into any of the three fields with a value less than 60. You could of course customize the values to whatever you need.


if (($values["Reading"] < 60) || ($values["Math"] < 60) || ($values["Science"] < 60)) {
$email = "email@email.com";

$subject = "Your Student's Recent Test Score(s)";

$message = "We would like to inform you of your child's latest test scores." . "\n\n";

$message .= "Reading: " . $values["Reading"] . "\n";

$message .= "Math: " . $values["Math"] . "\n";

$message .= "Science: " . $values["Science"] . "\n\n\n";

$message .= "Please feel free to contact your child's instructor if you feel you need to discuss your child's performance.";
mail($email, $subject, $message);
}


Let me know if I can be of any further assistance. Hopefully that will work for you though and I won't have to give you any more bad code. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=14283&image=2&table=forumreplies' class='bbc_emoticon' alt=':P' />

L
larsonsc 1/5/2007

Fantastic TonyD! Glad that worked out for you.