如何通过电子邮件发送这些oracle结果

时间:2015-02-09 07:58:31

标签: php oracle plsqldeveloper

ECILE   TOTAL_DECILE_COUNT  FULL_KYC    PERCENTAGE
--------------------------------------------------
Decile 9    5091             1936           38.03
Decile 8    12472           5580            44.74
Decile 7    29927           14838           49.58
Decile 6    36481           18770           51.45
Decile 5    33460           18356           54.86
Decile 4    30454           17010           55.85
Decile 3    24243           14175           58.47
Decile 2    16912           8245            48.75
Decile 10   4231            2122            50.15
Decile 1    8801            4835            54.94
Bal.barred  1188354        115601           9.73

我运行脚本后得到这个表。但是我如何通过电子邮件发送? 任何帮助将受到高度赞赏。

<?php
ini_set('max_execution_time', 0);
ini_set('memory_limit', '1500M');
$c = oci_pconnect("xxx", "xxx", "xxxx");
if (!$c) {
$e = oci_error();
trigger_error('Could not connect to database: '. $e['message'],E_USER_ERROR);
}
$s = oci_parse($c, "WITH 
  dcl AS (
 select count(n.msisdn) FULL_KYC,case when n.decile_group is NULL then 'Bal.barred' else n.decile_group end decile_group  
from (select distinct (a.msisdn)msisdn,b.segment,b.decile_group 
from table1 a full join table2 b on a.msisdn=b.msisdn)n,
(select distinct msisdn from (
            select case
              when substr(msisdn,1,1) = '7' then ''||msisdn
              when substr(msisdn,1,1) = '0' then ''||substr(msisdn,2,9)
            else msisdn end msisdn from table3))p
where n.msisdn=p.msisdn
group by n.decile_group),

base as (select decile,total_decile_count from table4 )

select base.decile, base.total_decile_count,dcl.full_kyc,round(((dcl.full_kyc/base.total_decile_count)*100),2) Percentage
from dcl left join base on base.decile=dcl.decile_group order by base.decile desc");


if (!$s) {
$e = oci_error($c);
trigger_error('Could not parse statement: '. $e['message'], E_USER_ERROR);
}
$r = oci_execute($s);
if (!$r) {
$e = oci_error($s);
trigger_error('Could not execute statement: '. $e['message'], E_USER_ERROR);
}
echo "<table border='1'>\n";
$ncols = oci_num_fields($s);
echo "<tr>\n";
for ($i = 1; $i <= $ncols; ++$i) {
$colname = oci_field_name($s, $i);
echo " <th><b>".htmlentities($colname, ENT_QUOTES)."</b></th>\n";
}
echo "</tr>\n";
while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>".($item!==null?htmlentities($item,
ENT_QUOTES):"&nbsp;")."</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
?>

1 个答案:

答案 0 :(得分:0)

不要回应你的桌子。将它添加到像这样的变量

$mailbody .= 'Even more text';

然后使用PHPMailer或Swift发送邮件。我建议使用最可靠的SMTP传输。