This topic is locked

Send email with table of orders

10/20/2017 8:54:34 PM
PHPRunner General questions
Z
zupermanzito author

ok, first of all, this might be hard, english is not my native lenguage. so ill try to explain my self as the best i can.
right now i need to send email to selected users with a query from order table ( right now im in customers table)
i have read how to send email
what i need is to change $body to a query consisting of:
"SELECT pagocxc.fecha, pagocxc.cliente, pagocxc.monto, pagocxc.obs FROM pagocxc WHERE cliente = '".$c_cod."' AND idventa = 0 AND monto >0"

and make it a loop so ill get a table
consisting on:

Fecha cliente Monto Obs

10-10-17 01 $100 Observaciones 1

10-12-17 01 $120 observaciones 2
To be honest i rather not deal with DAL, and just stick with normal MYSQL. since im not a a programer of any sort, i feel i understand a bit better.
i know 90% for sure this code might work with some tweeks, but then again im not a programer after all.
$body = "";

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

{
$result = mysql_query('SELECT

pagocxc.fecha,

pagocxc.cliente,

pagocxc.monto,

pagocxc.obs

FROM

pagocxc

WHERE cliente = '".$c_cod."' and

idventa = 0 and

monto >0');
$body= "<h1>Table 1</h1>

<table>

<thead>

<tr>

<th>fecha</th>

<th>cliente</th>

<th>monto</th>

<th>obs</th>

</tr>

</thead>

<tbody>";
while ($row = mysqli_fetch_array($result))

{
echo '<tr>

<td>'.$row['fecha'].'</td>

<td>'.$row['cliente'].'</td>

<td>'.$row['monto'].'</td>

<td>'.$row['obs'] . '</td>

</tr>';
}
$body = (what to do here?)
}
// send the email

$email = "emai@email.com";

$subject = "subjet";

$arr = runner_mail(array('to' => $email, 'subject' => $subject,'htmlbody' => $body, 'charset' => 'UTF-8'));
$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;

}
i know for a fact that where i had the comic sans is where the mistake lies.
any help or pointing in the right direction would be helpful.

thanks for the patient of reading my post

HJB 10/21/2017

https://xlinesoft.com/massmailer
... for inspiration purposes only.

Sergey Kornilov admin 10/23/2017

Instead of outputting information to the screen using 'echo' command you need to assign it to $body variable similar to what we do in this example:

https://www.xlinesoft.com/phprunner/docs/email_selected_records.htm

while ($row = mysqli_fetch_array($result))

{
$body .= '<tr>

<td>'.$row['fecha'].'</td>

<td>'.$row['cliente'].'</td>

<td>'.$row['monto'].'</td>

<td>'.$row['obs'] . '</td>

</tr>';
}
Z
zupermanzito author 10/28/2017



Instead of outputting information to the screen using 'echo' command you need to assign it to $body variable similar to what we do in this example:

https://www.xlinesoft.com/phprunner/docs/email_selected_records.htm


Im sorry Sergey.
im afraid its not working. sadly im not a very good php programmer all i know is by "reading"
so fair i have this:

[media]https://ibb.co/dNhZFm[/media]
now i need the "test" button to send email to my costumer
the code i have so far Which i have changed from the first post



$body = "";

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

{

$c_cod = $data['c_cod'];

$result = mysqli_query("SELECT

pagocxc.fecha,

pagocxc.cliente,

pagocxc.monto,

pagocxc.obs

FROM

pagocxc

WHERE cliente = ".$c_cod." and

idventa = 0 and

monto >0");
}
while ($row = mysqli_fetch_array($result))

{
$body .= '<tr>

<td>'.$row['fecha'].'</td>

<td>'.$row['cliente'].'</td>

<td>'.$row['monto'].'</td>

<td>'.$row['obs'] . '</td>

</tr>';
}
// send the email

$email = "emai@email.com";

$subject = "subjet";

$arr = runner_mail(array('to' => $email, 'subject' => $subject,'htmlbody' => $body, 'charset' => 'UTF-8'));
$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;

}


right now is not even sending email. i trully dont know what to do.

<td>'.$row['fecha'].'</td>

<td>'.$row['cliente'].'</td>

<td>'.$row['monto'].'</td>

<td>'.$row['obs'] . '</td>

</tr>';



this fields are in detailed table.

Z
zupermanzito author 10/28/2017



https://xlinesoft.com/massmailer
... for inspiration purposes only.



to be honest i have it, however i don't see much of a documentation, i have lost faith in it.. i don't see many examples or how use it besides that single page.

HJB 10/29/2017



to be honest i have it, however i don't see much of a documentation, i have lost faith in it.. i don't see many examples or how use it besides that single page.



Excerpt out of given URL, I see TWO different tables, i.e. LOGIN and INVOICES, plus of course many more can be added as many as different tables inside the

project are existing ..., the developers documentation is fully sufficient as selection of relevant table by means of SELECT "table" is one step and second

one is to set the WHERE criteria then, something which is as well happening inside PHPR under SQL QUERY, say, if one is not sure on how to do it, one can

simulate his SQL query inside PHPR then and can copy it into the MassMailer then.

Sergey Kornilov admin 10/30/2017

MassMailer template is not a code that you can use. It is a template that does similar job and it was a suggestion to check that template instead of inventing a bicycle.
If you want to implement this on your own you need to troubleshoot your code. This article explains how to troubleshoot custom buttons:

https://xlinesoft.com/phprunner/docs/troubleshooting_custom_buttons.htm
Generally speaking here basic troubleshooting steps:

  1. Make sure that simple email sent to single recipient works
  2. Send a simple hardcoded email to multiple recipients in the loop
  3. Now you can build the complete code and test it.
    It is important to understand what exactly doesn't work, troubleshoot one feature at the time.

HJB 11/2/2017



MassMailer template is not a code that you can use. It is a template that does similar job and it was a suggestion to check that template instead of inventing a bicycle.
If you want to implement this on your own you need to troubleshoot your code. This article explains how to troubleshoot custom buttons:

https://xlinesoft.com/phprunner/docs/troubleshooting_custom_buttons.htm
Generally speaking here basic troubleshooting steps:

  1. Make sure that simple email sent to single recipient works
  2. Send a simple hardcoded email to multiple recipients in the loop
  3. Now you can build the complete code and test it.
    It is important to understand what exactly doesn't work, troubleshoot one feature at the time.


@admin, ... Massmailer3 being out, with Twilio SMS option aboard, my question is this: Can Twilio SMS Dual-Gateway become an option any time from now? Say, with commercially available 800'000 US Medical DB records in hands, there is definitely potential around to bless JADACH with a pre-XMAS gift, say, expansion from his current 4 to all US hospitals, on let me simply say, top offers for ObamaCare system-leakages.