Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Utorok, 17. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Adding column values together.

phpMyEdit General     Adding column values together.
Odoslať novú tému   Odpovedať na tému    
 
oldwolfe     Založený: 18.05.2009   Príspevky: 2  
Príspevok Zaslal: 2009-05-18 04:06
Návrat hore  Odpovedať s citátom     

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     Založený: 18.05.2009   Príspevky: 2  
Príspevok Zaslal: 2009-05-20 11:53
Návrat hore  Odpovedať s citátom     

$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.

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov