简体   繁体   English

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

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

I have this sql query select count(n.msisdn) FULL_KYC, decile_group 我有这个sql查询select count(n.msisdn)FULL_KYC,decile_group
from Table1 从表1

The results I get here are the numbers(FULL_KYC) and decile_group(from decile 1 to decile 10). 我得到的结果是数字(FULL_KYC)和decile_group(从十分位数1到十分位数10)。 I need to be able to add this results to a table in php including a new row down for totals of each column. 我需要能够将此结果添加到php中的表中,包括每列总计的新行。 I am using oracle database and connecting remotely. 我正在使用oracle数据库并进行远程连接。 Many thanks 非常感谢

The short answer is that you need a web server with php and oracle extension for php. 简短的回答是你需要一个带php和oracle扩展的web服务器。 Then you can use the oracle connector for Php and launch the query, retrieve data and show them with an html table. 然后,您可以使用Php的oracle连接器并启动查询,检索数据并用html表显示它们。

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

Bye 再见

For accomplish the complete request you can change 为了完成完整的请求,您可以更改

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";

in

    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