![](/img/trans.png)
[英]fetch multiple query results and display into table using php with 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) : " ") . "</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";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.