This topic is locked

Email from named Table

9/21/2007 12:22:58 PM
PHPRunner General questions
L
Lisa2006 author

Can someone please help...........
I have created 2 table as follows:
Table 1: suppliers

Field: country

Field: import (checkbox)

Field: export (checkbox)

Field: importandexport (checkbox)

Feild: email
Table 2: quotes

Field: companyname

Field: shipping
This is what is suppose to happen:
Users fill the quote table with there companyname and shipping details. The shipping field is a drop down list containing the following 3 items: Germany, Sweden & France.
Suppliers fill in the suppliers table with there information. Again, The country field is a drop down list containing the following 3 items: Germany, Sweden & France. The Suppiers check whether they import, export or importandexport.
I want to be able to do the following from quotes:
On the edit page, I want to be able to click a "SEND EMAIL" link. As an example, if the shipping field contains Germany, then the supplier table country field is checked for all records containing Germany. If true, then the companyname & shipping field details from the quote table are sent to the email held in the supplier table.
Your help would be much appreciated....
Lisa

J
Jane 9/24/2007

Lisa,
I recommend you to use Before record added event on the Events tab for this purpose.

Here is a sample code:

global $conn;

$str = "select email from suppliers where country='".$values["shipping"]."'";

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

if ($data = db_fetch_array($rs))

{

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

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

$subject="your subject";

$email=$data["email"];
mail($email, $subject, $message);

}


Also you can add new field (Send_email for example) to the quotes table and set up this field as checkbox on the Visual Editor tab. If Send_email is true email is sent:

if ($values["Send_email"])

{

//send email here

}