This topic is locked

how to add two actions single button

2/13/2020 11:57:21 AM
PHPRunner General questions
Z
zupermanzito author

right now following this tutorial
https://xlinesoft.com/phprunner/docs/email_selected_records.htm

$body = "";

while( $data = $button->getNextSelectedRecord() )

{

$body .= "OrderID: " . $data['OrderID'] . "\n";

$body .= "Customer: " . $data['CustomerID'] . "\n";

$body .= "Employee: " . $data['EmployeeID'] . "\n-----------\n\n";

$email = $data['correo'];
}



// send the email

$subject = "Sample subject";

$arr = runner_mail(array('to' => $email, 'subject' => $subject,'body' => $body));



$result["txt"] = "Emails were sent.";



// 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;

}


now i need that if the email function works i want to update a field

i was trying to add this:

while($record = $button->getNextSelectedRecord())

{

$sql = "update Invoices set Status='Paid' where InvoiceID=" .$record["InvoiceID"];

DB::Exec($sql);

}



but its not working any ideas?

Z
zupermanzito author 2/25/2020

any ideas ? please gurus



right now following this tutorial
https://xlinesoft.com/phprunner/docs/email_selected_records.htm

$body = "";

while( $data = $button->getNextSelectedRecord() )

{

$body .= "OrderID: " . $data['OrderID'] . "\n";

$body .= "Customer: " . $data['CustomerID'] . "\n";

$body .= "Employee: " . $data['EmployeeID'] . "\n-----------\n\n";

$email = $data['correo'];
}
// send the email

$subject = "Sample subject";

$arr = runner_mail(array('to' => $email, 'subject' => $subject,'body' => $body));
$result["txt"] = "Emails were sent.";
// 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;

}


now i need that if the email function works i want to update a field

i was trying to add this:

while($record = $button->getNextSelectedRecord())

{

$sql = "update Invoices set Status='Paid' where InvoiceID=" .$record["InvoiceID"];

DB::Exec($sql);

}



but its not working any ideas?