Hello all

I have this query

$query_Totals_i = "SELECT (kinisis_1c + kinisis_1e + ((kinisis_1c / kinisis_1b) * kinisis_1a)) * (1 - fpa) * 1.005 AS kinisis_1,   (100c+ 100e+ ((100c/ 100b) * 100a)) * (1 - fpa) * 1.005 AS `100ara`,   (super_1c + super_1e + ((super_1c / super_1b) * super_1a)) * (1 - fpa) * 1.005 AS super_1,   (95_1c+ 95_1e+ ((95_1c/ 95_1b) * 95_1a)) * (1 - fpa) * 1.005 AS `95_1`,   (95_2c+ 95_2e+ ((95_2c/ 95_2b) * 95_2a)) * (1 - fpa) * 1.005 AS `95_2`,   (super_2c + super_2e + ((super_2c / super_2b) * super_2a)) * (1 - fpa) * 1.005 AS super_2,   (kinisis_2c + kinisis_2e + ((kinisis_2c / kinisis_2b) * kinisis_2a)) * (1 - fpa) * 1.005 AS kinisis_2 FROM kiniseis WHERE `date` BETWEEN '$_GET[date1]' AND '$_GET[date2]'";

$Totals_i = mysql_query($query_Totals_i, $gas_connection) or die(mysql_error());
$row_Totals_i = mysql_fetch_assoc($Totals_i);
$totalRows_Totals_i = mysql_num_rows($Totals_i);

This query produces 7 different preudo columns that has the result of the formula you see inside of each one of it.Ofcourse there are many records in the database , so i thought to make a total sum of each row dynamically using array_sum() function.

I tried this script below.(for the sum of the 1st pseudo-column kinisis_1)

$i1 = array($row_Totals_i['kinisis_1']);
echo "" . array_sum($i1) . "\n";

But it compute only the starting record result and not all included records,between the dates given.

I know the code is not correct, so i would like to ask how to alter this script to do the job i want it to do :)

Thanks in advance

What is the structure of: $row_Totals_i

Please do a dump of it to see it's structure and post it here.

eg:

var_dump($row_Totals_i);

With the limited info given, it is hard to get what is wrong.

Member Avatar for rajarajan2017
$query_Totals_i = "SELECT (kinisis_1c + kinisis_1e + ((kinisis_1c / kinisis_1b) * kinisis_1a)) * (1 - fpa) * 1.005 AS kinisis_1,   (100c+ 100e+ ((100c/ 100b) * 100a)) * (1 - fpa) * 1.005 AS `100ara`,   (super_1c + super_1e + ((super_1c / super_1b) * super_1a)) * (1 - fpa) * 1.005 AS super_1,   (95_1c+ 95_1e+ ((95_1c/ 95_1b) * 95_1a)) * (1 - fpa) * 1.005 AS `95_1`,   (95_2c+ 95_2e+ ((95_2c/ 95_2b) * 95_2a)) * (1 - fpa) * 1.005 AS `95_2`,   (super_2c + super_2e + ((super_2c / super_2b) * super_2a)) * (1 - fpa) * 1.005 AS super_2,   (kinisis_2c + kinisis_2e + ((kinisis_2c / kinisis_2b) * kinisis_2a)) * (1 - fpa) * 1.005 AS kinisis_2 FROM kiniseis WHERE `date` BETWEEN '$_GET[date1]' AND '$_GET[date2]'";
echo $query_Totals_i;

Then you can have a query output on the browser, copy and paste it in the phpadmin sql editor and check whether it returning the rows properly. If not the query is not well formed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.