【发布时间】:2015-02-12 14:08:57
【问题描述】:
我有这个 sql 查询
选择计数(n.msisdn)FULL_KYC,decile_group
来自表 1
我在这里得到的结果是数字(FULL_KYC)和 decile_group(从十分位 1 到十分位 10)。我需要能够将此结果添加到 php 中的表中,包括每列总计的新行。我正在使用 oracle 数据库并远程连接。 非常感谢
【问题讨论】:
我有这个 sql 查询
选择计数(n.msisdn)FULL_KYC,decile_group
来自表 1
我在这里得到的结果是数字(FULL_KYC)和 decile_group(从十分位 1 到十分位 10)。我需要能够将此结果添加到 php 中的表中,包括每列总计的新行。我正在使用 oracle 数据库并远程连接。 非常感谢
【问题讨论】:
简短的回答是,您需要一个带有 php 和 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) : " ") . "</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) : " ") . "</td>\n";
}
print "</tr>\n";
}
print "<tr>\n";
foreach ($finalRow as $item) {
print " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
print "</tr>\n";
print "</table>\n";
【讨论】: