Hi Everyone,
I need help with a button please. Maybe some one can help me. I used the example from the manual called "Email selected records", but what I really need is to insert those selected records into another table. I modified the code but it didn't work. Here is the code.
Thanks for your help.
global $dal;
$dal_TableName = $dal->Table("ies_case_log");
$body="";
foreach(@$keys as $keyblock)
{
$arr=explode("&",refine($keyblock["log_id"]));
if(count($arr)<1)
continue;
$arr2=array();
$arr2["log_id"]=urldecode(@$arr[0]);
$where = KeyWhere($arr2);
$rstmp = $dal_TableName->Query($where,"");
$datatmp=db_fetch_array($rstmp);
$sql = "INSERT INTO coor_case_log (log_id,case_no,log_date,client_name,log,done_by) VALUES ('".$datatmp['log_id']."','".$datatmp['case_no']."','".$datatmp['log_date']."',
'".$datatmp['client_name']."','".$datatmp['log']."','".$datatmp['done_by']."')";
db_exec($sql,$conn);
$body .= "Case No." . $datatmp['case_no']. "\n";
$body .= "Client Name." . $datatmp['client_name']. "\n";
$body .= "Log Date: " . $datatmp['log_date'] . "\n";
$body .= "Notes: " . $datatmp['log'] . "\n";
$body .= "Done By: " . $datatmp['done_by'] . "\n-----------\n\n";
}
// send the email
$email="joanb@iessi.com";
$subject="Testing Notes";
$arr = runner_mail(array('to' => $email, 'subject' => $subject,
'body' => $body));
$result["txt"] = "Files Notes Were Transferred";
// if error happened print a message on the web page
if (!$arr["mailed"])
{
$errmsg = "Error happened:
";
$errmsg.= "File: " . $arr["errors"][0]["file"] . "
";
$errmsg.= "Line: " . $arr["errors"][0]["line"] . "
";
$errmsg.= "Description: " . $arr["errors"][0]["description"] . "
";
$result["txt"] = $errmsg;
}