Hi all
Hopefully someone can point me in the right direction with the following problem which I have spent hours trying to figure out.
I have a table which is only displayed as a list - no add or edit facility is required. From list, users are able to select (using checkbox next to view icon) multiple records of interest. Once selected, by hitting custom button with server event code, an email is sent to the site owner and also the customer and this all works fine.
The code used and working is as follows:
$email_msg = "";
$i=1;
while($data = $button->getNextSelectedRecord())
{
$email_msg.= "User ID: ".$_SESSION[biouserID]."\r\n";;
$email_msg.= "Number: ".($i++)."\r\n";
$email_msg.= "Record ID: ".$data["ID"]."\r\n";
$email_msg.= "Case Number: ".$data["Case_Number"]."\r\n";
$email_msg.= "Description: ".$data["Description"]."\r\n";
$email_msg.= "\r\n";
$email_msg.= "\r\n";
}
//send email
$email = "@.co.uk";
$subject = $_SESSION[UserName] . " " . "(".$_SESSION[email].")". " Interested in the following: ";
runner_mail(array('to' => $email, 'cc' => $_SESSION[email], 'subject' => $subject, 'body' => $email_msg));
}
and this is text of the email received from the above :
User ID: 1
Number: 1
Record ID: 1
Case Number: BM08-000001
Description: bone marrow biopsy with aspiration is a 1.5 cm red tan bone core biopsy (A1); bone marrow aspirate in formalin is filtered for spicules (A2). Also received are 13 bone marrow aspirate smears 0 touch preps 1 peripheral smear 0 EDTA bone marrow aspirate 0 sodium heparin bone marrow aspirate and a CBC result. PRZ/vk/ejs
========================================
What I am now trying to achieve is that as well as sending an email, I want to record the UserName and Case Number into a new table in the same database named Enquiries so that the site owner can keep record of who is interested in what.
I have found an article on how to UPDATE multiple records and tried changing to INSERT
while ( $data = $button->getNextSelectedRecord() ) {
// set ReportsTo field to 'Bob Smith'
$sql = "INSERT INTO Enquiries (BioID, Case_Number) values ($data['ID'],$data['Case_Number'])";
CustomQuery($sql);
}
However, this does not work but also does not give an error and the email side stops working.
Any help greatly appreciated (phprunner 9.8)
Thank you
Andrew