So heres my code, any idea how I can apply this to this. I need to count the $test and multiply assoc1[$test] and assoc2[$test] by these figures:
$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];
}