This topic is locked

email form help

5/31/2007 10:04:05 AM
PHPRunner General questions
G
Greeham author

Hi All,
I have set up a Request Form and once completed I would like to email our administrator with the contents of the form. Sounds straight forward but, some of our parts are made up of several smaller parts. I have set up a 'Masterparts' table and a assemblies table. They are linked via a partid and what i would like to happen is that when someone requests a part made up of several smaller parts, rather than the administrator look it all up, she/he gets an email with a list of the smller parts?
Does that make sense? And if so, is this possible?
Thanks,

Sergey Kornilov admin 5/31/2007

I think you need to write a BeforeAdd event to retrieve a list of smaller parts for each part, combine everything into a message body and email it.

G
Greeham author 6/1/2007

I think you need to write a BeforeAdd event to retrieve a list of smaller parts for each part, combine everything into a message body and email it.


Hi Sergey,
Thanks for getting back to me, I am fairly new to the code involved in the events and am unsure of how I would go about this. If you have the time to give me a snippet of an idea of how to attain the result I wanted I would be most grateful.
Thanks,

J
Jane 6/1/2007

Hi,
it's difficult to write event code without your actual data.

Please post here structure of your tables and detailed description of what you want to achieve. I'll try to help you.

G
Greeham author 12/14/2007

Hi,

it's difficult to write event code without your actual data.

Please post here structure of your tables and detailed description of what you want to achieve. I'll try to help you.


Hi Jane,
I forgot I had asked this some time ago and the project has now come back again.
I have 2 tables, requests and spares.
In requests there are the fields a,b,part_no,c and d

In spares I have a,part_no,part_name and location.
I have a look up in requests to look at part_name from result of part_no.
Some part_no's are an assembly and made up of smaller parts. I would like that when a particular part_no is selected in requests that in the email that is sent as a result the smaller part numbers are included in the email rather than the main part_no
I hope this makes more sense...
Thanks,
Graham

J
Jane 12/14/2007

Greeham,
here is a sample code:

global $conn;

$str = "select part_name from spares where part_no=".$values["part_no"];

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

$data = db_fetch_array($rs);
$email="test@test.com";

$message="";

$subject="New data record";
foreach($values as $field=>$value)

$message.= $field." : ".$value."\r\n";
$message.= "Part Name: ".$data["part_name"]."\r\n";

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

G
Greeham author 12/14/2007

Hi Jane,
Presumably I would need an addtional table with the main part_no's and there smaller parts to be able to cross reference them?
Thanks again for your help,
Graham

J
Jane 12/14/2007

Greeham,
to select details from another table use the same code:

global $conn

$str = "select * from MainTable where part_no=".$values["part_no"];

$rs = db_query($str);

$data = db_fetch_array($rs);


All values from MainTable are in the $data array now.