My data is stored like this:
//id// //amount//
12-0 //20
12-1 //20
45-0 //17
and displays like this:
//id// //amount//
12 //20
45 //17
And I need it to display like this
//id// //amount//
12 //40
45 //17
How do I do this?
My code:
$typesSQL = "(SELECT grptype, grpid FROM user_tasks WHERE custid = '$username' AND buildid = '$buildingid') ORDER BY grpid";
$typesResults = mysql_query ($typesSQL);
while ($typesRow = mysql_fetch_assoc ($typesResults)){
$explode = explode("-",$typesRow['grpid']);
$test = $explode[0];
//$test = $typesRow["grpid"];
$types[$test] = $typesRow["grptype"];
$testSQL = "(SELECT fvalue FROM user_tasks WHERE grptype = '$types[$test]' AND grpid = grpid AND custid = '$username' AND buildid = '$buildingid' AND areaqty = 'Area' AND catname='Hard Floor Care') ORDER BY grpid";
$testResults = mysql_query ($testSQL);
$testRow = mysql_fetch_array ($testResults);
$assoc1[$test] = $testRow["fvalue"];
$test1SQL = "(SELECT fvalue FROM user_tasks WHERE grptype = '$types[$test]' AND grpid = grpid AND custid = '$username' AND buildid = '$buildingid' AND areaqty = 'Area' AND catname='Carpet Care') ORDER BY grpid";
$test1Results = mysql_query ($test1SQL);
$test1Row = mysql_fetch_array ($test1Results);
$assoc2[$test] = $test1Row["fvalue"];
$assoc[$test] = $assoc1[$test] + $assoc2[$test];
}