Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Adding column values together.

phpMyEdit General     Adding column values together.
Post new topic   Reply to topic    
 
oldwolfe     Joined: 18 May 2009   Posts: 2  
Post Posted: 2009-05-18 04:06
Back to top  Reply with quote     

Greetings to the forum Members.

I need some assistance with adding integer values together in a column. I am only using one table.

An Example

Values are input into this column named- FuelAmtLtrs

FuelAmtLtrs
0
0
30
5
0
7

and have the results obtained inserted to another column
named TotalFuelAmtLtrs


0
0
30
35
35
42

Basically a progressive sum.

Since my original post I have managed to create a query to get the sum of the amounts of fuel purchased and this query works in phpmyadmin

SELECT `TotalFuelAmtLtrs`,SUM(`FuelAmtLtrs`) FROM TA
GROUP BY `TotalFuelAmtLtrs`

Basically the sum of all column values.

How do i incorporate this query into index.php?

Regards
oldwolfe

 
oldwolfe     Joined: 18 May 2009   Posts: 2  
Post Posted: 2009-05-20 11:53
Back to top  Reply with quote     

$opts['fdd']['FuelAmtLtrs'] = array(
'name' => 'FuelAmtLtrs',
'select' => 'T',
'maxlen' => 11,
'sort' => true
);
$opts['fdd']['TotalFuelAmtLtrs'] = array(
'name' => 'TotalFuelAmtLtrs',
'select' => 'T',
'maxlen' => 8,
'sort' => true
);

$dbhandle3 = mysql_connect('localhost', 'username', 'pass');

if ($dbhandle3 == false)
{
die ("Unable to connect to MySQL Database<br>");
}

$db = mysql_select_db('klms');

if ($db == false)
{
die ("Unable to Select MySQL Database<br>");
}

$dbquery3 = 'SELECT `TotalFuelAmtLtrs` , SUM( `FuelAmtLtrs` ) FROM TA '
. ' GROUP BY `TotalFuelAmtLtrs` LIMIT 0, 30 ';

$dbresult3 = mysql_query($dbquery3, $dbhandle3);

if ($dbresult3 == false)
{
die ("Unable to to perform query<br>");
}

while ($dbrow3 = mysql_fetch_row($dbresult3)) {
foreach($dbrow3 as $key => $value) {
print "Total Fuel Used Is " . "$dbrow3[$key]" . " ";
echo "<br>";
}
}

I have found a partial solution from Techotopia which calculates the column sum and displays them above the table. I would like to place the value of
$dbrow3($dbresult3) back into the column TotalFuelAmtLtrs.

Can anyone assist.

Regards
Oldwolfe.

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy