【问题标题】:customizing oracle query results into a table with php用php自定义oracle查询结果成表
【发布时间】:2015-02-12 14:08:57
【问题描述】:

我有这个 sql 查询 选择计数(n.msisdn)FULL_KYC,decile_group
来自表 1

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

【问题讨论】:

    标签: php sql oracle


    【解决方案1】:

    简短的回答是,您需要一个带有 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) : "&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";
    

    【讨论】:

    • 谢谢伙计。唯一的问题是查询结果将完全按照原样出现在表中。 yt 我需要所有列的总计和使用查询结果计算的其他一些基本聚合。
    • 非常感谢。这里有很大的帮助。
    猜你喜欢
    • 2020-10-24
    • 1970-01-01
    • 2016-03-16
    • 1970-01-01
    • 1970-01-01
    • 2016-04-07
    • 2012-07-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多