Hi guys,
I've been struggling with getting this right, so I'm trying here to see if I can get some help.
I'm trying to do two things.
First..
I have a form where a user has to choose an email address (lookup field to another table for choosing among registered users).
I want to extract the email adress ($emailaddr) that the user has chosen and send that user an email.
Here's the code (Hooks)
function Tbl_Goods_after_insert($data, $memberInfo, &$args) {
$emailaddr = sql("Select Email from Tbl_Receivers where ID='{$data['Receiver']}'", $eo
);
foreach($data as $field => $value){
$messageData .= "$field: $value \n";
}
sendmail(array(
'to' => $emailaddr,
'name' => $emailaddr,
'subject' => 'Du har fått en leverans',
'message' => "Du har fått följande leverans till lagret på Telefonplan: \n\n" . $messageData
));
return TRUE;
}
My page just stops working when I enter this code (I've tried it in multiple ways and the query in works directly on the Database). If i remove the SQL query it all works fine (with hardcoded email address).
Second..
I have another field (on the same form) where the user is to enter a parcel tracking number (only digits). After insert (same hook as above) I want change the existing (but empty) field "Sender" IF it matches a record in another table (Table_Senders) where I have entered the first 6 digits and the sender's name on the records (Example: Parcel numbers starting with 123456 is from Supplier X..).
I'm to lousy at advanced SQL queries, so it someone could point me in the right direction I would much appreciate it!
B.r
Joakim
SQL lookup and matching
SQL lookup and matching
Kind regards,
JR
JR