How to SUM value using PHP function for ORACLE -


kindly me.

i want create summary raw database. example:

id | vessel name | tonnage |  1      abc         1000   2      cde         2000   3      efg         3000  

6000 <-- how total value using php , oracle?

for information, below code:

 $conn = ......;    $strsql = .....;    $objparse = oci_parse ($conn, $strsql);    oci_execute ($objparse);    while($objresult = oci_fetch_array($objparse,oci_both))    {     echo $objresult["id"];     echo $objresult["vslnm"];     echo $objresult["ton"];    } 

my question: there way using php function sum tonnage value. want grand total tonnage.

its trivial, add variable define outside loop:

   $conn = ......;    $strsql = .....;    $objparse = oci_parse ($conn, $strsql);    oci_execute ($objparse);    $total_tonnage = 0;    while($objresult = oci_fetch_array($objparse,oci_both))    {     echo $objresult["id"];     echo $objresult["vslnm"];     echo $objresult["ton"];     $total_tonnage += $objresult["ton"];    }    echo $total_tonnage; 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -