I want to output the information from this page to a email: with what I have I only get the last line of the output.
[php][
<?php
$grandTotal = 0;
$connect =odbc_conmation from this nect("removed");
if(!$connect) {
exit("Connection Failed: " . $connect);
}
#echo 'Open Orders';
$sql="select
case
when rtrim(so.uompfurnhold) in ('0','1','') then 'Released'
when rtrim(so.uompfurnhold) ='2' then 'Product'
when rtrim(so.uompfurnhold) ='3' then 'Minimal'
when rtrim(so.uompfurnhold) ='4' then 'Customer'
else 'GO' end as OrdStatus,
count(SO.ompSalesOrderID) as orders,round(sum(SO.ompOrderSubTotalBase),2) as total
FROM m1_kf.dbo.SalesOrders SO
Where so.ompClosed !=-1
Group by case
when rtrim(so.uompfurnhold) in ('0','1','') then 'Released'
when rtrim(so.uompfurnhold) ='2' then 'Product'
when rtrim(so.uompfurnhold) ='3' then 'Minimal'
when rtrim(so.uompfurnhold) ='4' then 'Customer'
else 'GO' end ";
$result =odbc_exec($connect,$sql);
if(!$result){
exit("Error in SQL");
}
echo "Open Orders ". date("m-d-Y") ;
echo "
";
echo "
";
echo "Status | ";
echo " | ";
echo "Orders | ";
echo " | ";
echo "Total |
";
while (odbc_fetch_row($result)) {
$OrdStatus=odbc_result($result,"OrdStatus");
$orders=odbc_result($result,"orders");
$total=odbc_result($result,"total");
$num = number_format($total, 2, '.', ',');
$grandTotal += $total;
echo "
$OrdStatus | ";
echo " ◃ | ";
echo "$orders | ";
echo " ▹ | ";
echo "$num |
";
}
#$num2 = number_format( $grandTotal, 2);
#echo "Grand Total: $num2";
odbc_close($connect);
//********************************************************************************
require_once "Mail.php";
require_once "Mail/mime.php";
$from = "removed";
#$to = "removed";
$to = "removed";
#$subject = "Status\r\n\r\n";
$subject='';
$text="";
$html = "";
$crlf = "\n";
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$host = "smtp.gmail.com";
$username = "removed";
$password = "removed";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$body = $mime->get();
$body="$OrdStatus > $num";
#$body ='Get the Info';
$headers = $mime->headers($headers);
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("
" . $mail->getMessage() . "
");
} else {
echo("
Message successfully sent!
");
echo $text;
}
?>
[/php]