2015-02-09 64 views
-1
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 

我运行我的脚本后得到这个表。但我如何通过电子邮件发送? 任何帮助将不胜感激。如何通过电子邮件发送这些oracle结果

<?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"; 
?> 
+0

使用'UTL_MAIL'功能在oracle中发邮件 – Exhausted 2015-02-09 07:59:41

回答

0

不要回显你的表格。将其添加到像这样的变量中

$mailbody .= 'Even more text'; 

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

+0

我对此感到高兴......任何人都可以为我包含该代码......我得到了来自Google的许多结果,而且我无法尽快将它们放在一起。谢谢 – 2015-02-09 13:20:18