Hello, I hope that someone can help me with my problem. I hope I can explain what I need

I have 2 sql queries for gathering and calculating personal information of employees. There I managed to get sum of workers paychek. Now I need to get sum from all paychecks (from every worker) for all dates. Example

Now I get this:
23.10.2009 Worker1 23,
23.10.2009 Worker2 20,
23.10.2009 Worker3 30
24.10.2009 Worker1 30
24.10.2009 Worker2 10

I need to become:
23.10.2009 All 73
24.10.2009 All 40

This thing wouldn't be complicated if I have these date in DB (23, 20, 30 ...) but I have to first calculate them and list them so I don't know how to use them again. Here is the code and please help me:


Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

<title>Workers</title>


</head>
<body>
<?php
			$datum=$_POST['chosenDate']; 	//First date - von
			$datum2=$_POST['chosenDate2'];	//Second date - bis
			$vonDatum=strtotime(date($datum,time())); 	//First date - von transformed into timestamp
			$bisDatum=strtotime(date($datum2,time()));	//Second date - bis transformed into timestamp


$query="SELECT s.datum, s.schicht, s.bargeld, au.stundenlohn, a.von, a.bis,
		s.bargeld, s.belege, s.gutschein, s.rechnung,  s.sonstiges,
		s.stand, s.putzgeld, s.fehlend, 
		s.kassiert
		FROM arbeitszeiten a, authuser au, schichtumsatz s 
		WHERE s.datum BETWEEN ".$vonDatum." AND ".$bisDatum."
		AND au.id=".$check["id"]." 
		AND a.mitarbeiterid = ".$check["id"]."
		AND a.schicht=s.id
		ORDER BY s.datum ASC
		";
	// I NEED THIS QUERY FOR TABLE WHERE I AM GOING TO SHOW FINAL RESULTS
$query2="SELECT s.datum, s.schicht, s.bargeld, s.kassiert, s.belege, s.gutschein, s.rechnung, s.sonstiges 
		FROM schichtumsatz s
		WHERE s.datum BETWEEN ".$vonDatum." AND ".$bisDatum."
		ORDER BY s.datum ASC	
		";
		
$query4="SELECT s.datum, s.schicht, s.bargeld, au.stundenlohn, a.von, a.bis, x.zeit 
		FROM arbeitszeiten a, authuser au, schichtumsatz s,
			( SELECT s.datum, s.schicht, sum(a.bis - a.von) As zeit
			  FROM arbeitszeiten a, schichtumsatz s 
			  WHERE a.schicht = s.id
			  AND s.datum BETWEEN ".$vonDatum." AND ".$bisDatum."
			  GROUP BY s.datum, s.schicht ) AS x
		WHERE s.datum BETWEEN ".$vonDatum." AND ".$bisDatum."
		AND au.id=".$check["id"]." 
		AND a.mitarbeiterid = ".$check["id"]."
		AND a.schicht=s.id
		AND s.datum = x.datum
		AND s.schicht = x.schicht
		ORDER BY s.datum ASC
		";
$connection = mysql_connect($dbhost, $dbusername, $dbpass); 
$SelectedDB = mysql_select_db($dbname); 
$result = mysql_query($query);          // query executed 
$result2 = mysql_query($query2);          // query executed
$result4 = mysql_query($query4);

echo mysql_error();              // if any error is there that will be printed to the screen

function stunden($von,$bis) {
//$von = $row["von"];
//$bis = $row["bis"];
$stunden = $bis - $von;
return $stunden;
}
?>
<div id="wrapper">


	<div>
	<h2><?php echo $check["uname"];?></h2>
	</div>

<?php	
$x=0.5;

while($row = mysql_fetch_array($result)){
///
///        THIS PART IS ONLY FOR CALCULATING ALL RESULTS
///
$row4 = mysql_fetch_array($result4);
$gesamt = stunden($row["von"], $row["bis"]);
$eingegeben = $row["bargeld"] + $row["belege"] + $row["gutschein"] + $row["rechnung"] + $row["sonstiges"];
$putzgeld=$x * $row4['zeit'];
$tgprost = $eingegeben - $row["stand"] - $putzgeld - $row["fehlend"];
$tgprost2 = $tgprost/ $row4['zeit'];
$tg = $gesamt * $tgprost2;

$umsatz = $eingegeben + $row["kassiert"];
$diff = $umsatz - $row["belege"];
$pro = $diff/$row4['zeit'];
$test = 52.5;

if($pro>$test){
	$provisionprostunde = 0.02*$umsatz/$row4['zeit'];
}else{
$provisionprostunde = 0;
}

$provision = $provisionprostunde * $gesamt;

$gehalt = $row["stundenlohn"] * $gesamt;
$gehalt2 = $gehalt + $tg + $provision; // I NEED TO CALCULATE THIS RESULT FOR ALL WORKERES ON DATE, NOW I CAN ONLY CALCULATE THIS FOR ONE SPECIFIC PERSON

///
///        END OF  CALCULATING PART
///
 
?>

		<tr>
			<td><?php echo $check["uname"]; ?></td>
			<td><?php echo date('d.m.Y',$row["datum"]); ?></td> 
			<td><?php echo $row["von"]; ?></td>
			<td><?php echo $row["bis"]; ?></td>
			<td><?php echo $gesamt?></td>
			<td><?php echo $row["schicht"]; ?></td>
			<td><?php echo $row["stundenlohn"];?></td> 
			<td><?php echo $gehalt?></td>
			<td><?php echo round($tgprost2,2)?></td>  
			<td><?php echo round($tg,2)?></td> 
			<td><?php echo round($provisionprostunde,2)?></td> 
			<td><?php echo round($provision,2)?></td>
			<td><?php echo round($gehalt2,2)?></td>
		</tr>

</table>
<?php
}
?>

<!-- IN THIS TABLE UNDER FIELD Gehalt SHOULD BE THIS WHAT I AM LOOKING FOR :)-->
<table border='1'>
		<tr>
			<th>Datum</th>
			<th>Schicht</th> 
			<th>Eingegeben</th>
			<th>Kassiert</th>
			<th>Umsatz</th>
			<th>Untersch. Belege</th>
			<th>Gutscheine</th>
			<th>Rechnung</th>
			<th>Sonst</th>
			<th>Gehalt</th>
			<th>Bar</th>
		</tr>
		

<?php
while($row2 = mysql_fetch_array($result2) ){

$eingegeben2 = $row2["bargeld"] + $row2["belege"] + $row2["gutschein"] + $row2["rechnung"] + $row2["sonstiges"];
$umsatz2 = $eingegeben2 + $row2["kassiert"];
$bar = $eingegeben2 - $row2["gutschein"] - $row2["rechnung"] - $row2["sonstiges"];
?>

		<tr>
			<td><?php echo date('d.m.Y',$row2["datum"]); ?></td>
			<td><?php echo $row2["schicht"]; ?></td> 
			<td><?php echo $eingegeben2?></td> 
			<td><?php echo $row2["kassiert"];?></td>
			<td><?php echo $umsatz2?></td>
			<td><?php echo $row2["belege"];?></td> 
			<td><?php echo $row2["gutschein"];?></td> 
			<td><?php echo $row2["rechnung"];?></td>  
			<td><?php echo $row2["sonstiges"];?></td>
			<td><?php echo '' ?></td>
			<td><?php echo $bar ?></td>
			
		</tr>

<?php 
}
?>
</table>

</body>
</html>
I don' know if I had explaind all well, but I hoep that someone could help me. Thanks