繁体   English   中英

使用php将Oracle查询结果定制到表中

[英]customizing oracle query results into a table with php

我有这个sql查询select count(n.msisdn)FULL_KYC,decile_group
从表1

我得到的结果是数字(FULL_KYC)和decile_group(从十分位数1到十分位数10)。 我需要能够将此结果添加到php中的表中,包括每列总计的新行。 我正在使用oracle数据库并进行远程连接。 非常感谢

简短的回答是你需要一个带php和oracle扩展的web服务器。 然后,您可以使用Php的oracle连接器并启动查询,检索数据并用html表显示它们。

这是一个示例: http : //php.net/manual/en/oci8.examples.php

再见

为了完成完整的请求,您可以更改

print "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
    print "<tr>\n";
    foreach ($row as $item) {
        print "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
    }
    print "</tr>\n";
}
print "</table>\n";

    print "<table border='1'>\n";
$finalRow = array();
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
    print "<tr>\n";

    foreach ($row as $key => $item) {
        $finalRow[$key] = (isset($finalRow[$key]) ? $finalRow[$key] : 0) + $item;
        print "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
    }
    print "</tr>\n";
}

print "<tr>\n";

foreach ($finalRow as $item) {
      print "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
}
print "</tr>\n";

print "</table>\n";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM