k4pil Posted March 9, 2006 Share Posted March 9, 2006 Hi there ppl!I think this question maybe a lil complex.I want to create a trigger in my mySql database which sends an email upon an event.I have a table case(caseID, custID, priority, subject, description, type, created, solved )When a new row is added which has priority = "high" i want the database to send an email to all the users from another table in the database;staff( userID, staff, access, username, password, name, surname, email )where access = "3". Email address is also recorded in this table.I have no idea how to do this.Anyone??Thanks in advance as always! Link to comment https://forums.phpfreaks.com/topic/4548-anyone-know-how-to-use-triggers-to-send-emails/ Share on other sites More sharing options...
joecooper Posted March 9, 2006 Share Posted March 9, 2006 cant really do it that way, why cant you add the email script to the page where the data is entered. egif priority = high then email... simple! Link to comment https://forums.phpfreaks.com/topic/4548-anyone-know-how-to-use-triggers-to-send-emails/#findComment-15909 Share on other sites More sharing options...
k4pil Posted March 9, 2006 Author Share Posted March 9, 2006 Ok,...but i have no idea of how to do it that way either...where do i start???Can you give me some help on what i need to do something like that?? Link to comment https://forums.phpfreaks.com/topic/4548-anyone-know-how-to-use-triggers-to-send-emails/#findComment-15954 Share on other sites More sharing options...
Gaia Posted March 9, 2006 Share Posted March 9, 2006 Just when you are inserting the information into the database add a chunk of code that sends an email below it. Link to comment https://forums.phpfreaks.com/topic/4548-anyone-know-how-to-use-triggers-to-send-emails/#findComment-15956 Share on other sites More sharing options...
Flinch Posted March 9, 2006 Share Posted March 9, 2006 Ya, if the data you are about to enter in the DB meets those qualifications you listed above, pull everyone out of the table staff that has an access level of >= 3, and then mail that.[code]$query = mysql_query("SELECT * FROM `staff` WHERE `access` >= '3'");if(mysql_num_rows($query) >= 1) { $sendto = ""; while($r = mysql_fetch_array($query) ) { if($sendto) { $sendto .= ",{$r['email']}"; } else { $sendto = $r['email']; } } //send the email mail($sendto, $subject, $body, "From: youremail@domain");}[/code]Something along those lines would do the trick. Link to comment https://forums.phpfreaks.com/topic/4548-anyone-know-how-to-use-triggers-to-send-emails/#findComment-15959 Share on other sites More sharing options...
k4pil Posted March 10, 2006 Author Share Posted March 10, 2006 Sooo simple...but soo effective.Ive been trying triggers, emailing scripts...u name it..lolThanks pps for showing me the light**SOLVED** Link to comment https://forums.phpfreaks.com/topic/4548-anyone-know-how-to-use-triggers-to-send-emails/#findComment-16102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.