Jump to content

How to return every row from


Begbie

Recommended Posts

Hello to everybody, I have problem and I hope that someone can help me.

I have function in where I make some calculation and store that information in one variable. So how can I return every row from this variable.

Variable (data) that I want to return is called $gesamt_gehalt.

And if I just make return $gesamt_gehalt I become only last data from that variable as return but I need all data. Can someone tell me how is it possible to get this. Should I use array or something. Please help. I am new to PHP so I hope I was understandable what I need :) Thanks in advance.

 

 

<?php
function getTableForUser2($id, $vonDatum, $bisDatum){ 

$user_data="SELECT s.datum, s.schicht, au.stundenlohn, a.von, a.bis,
	s.bargeld, s.belege, s.gutschein, s.rechnung,  s.sonstiges, s.umsatz,
	s.kassiert
	FROM arbeitszeiten a, authuser au, schichtumsatz s 
	WHERE s.datum BETWEEN ".$vonDatum." AND ".$bisDatum."
	AND au.id=".$id." 
	AND a.mitarbeiterid = ".$id."
	AND a.schicht=s.id
	ORDER BY s.datum ASC, schicht DESC
	";

$zeit_summe ="SELECT s.datum, s.schicht, s.bargeld, au.stundenlohn, a.von, a.bis, summe.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 summe
		WHERE s.datum BETWEEN ".$vonDatum." AND ".$bisDatum."
		AND au.id=".$id." 
		AND a.mitarbeiterid = ".$id."
		AND a.schicht=s.id
		AND s.datum = summe.datum
		AND s.schicht = summe.schicht
		ORDER BY s.datum ASC, s.schicht DESC
		";



$user_data_query = mysql_query($user_data);
$zeit_summe_query = mysql_query($zeit_summe);


echo mysql_error();  


$gesamt_gehalt = 0.;

while ($row_users2 = mysql_fetch_array($user_data_query)){

$row_users3 = mysql_fetch_array($zeit_summe_query);

$gesamt_zeit = stunden($row_users2["von"], $row_users2["bis"]);
$eingegeben = $row_users2["bargeld"] + $row_users2["belege"] + $row_users2["gutschein"] + $row_users2["rechnung"] + $row_users2["sonstiges"];

$gesamt_gehalt = 0.;
$x = 0.5;
$putzgeld = $x * $row_users3['zeit'];

$gehalt = $gesamt_zeit * $row_users2["stundenlohn"];

$row_stand_fehlend = getStand($row_users2["datum"]);
$stand = round($row_stand_fehlend["stand"]/14.,2);
$fehlend = round($row_stand_fehlend["fehlend"]/14.,2);
$tgprost = $eingegeben - $putzgeld - $stand - $fehlend;
$tgprost2 = $tgprost/ $row_users3['zeit'];
$tgprost2 = round($tgprost2,2);
$tg = $gesamt_zeit * $tgprost2;
$tg = round($tg,2);
$diff = $row_users2["umsatz"] - $row_users2["belege"];
$pro = $diff/$row_users3['zeit'];
$pro = round($pro,2);

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

$provisionprostunde = round($provisionprostunde,2);
$provision = $provisionprostunde * $gesamt_zeit;
$provision = round($provision,2);

$gesamt_gehalt = $gehalt + $tg + $provision;

}
return $gesamt_gehalt; 
}
?>

Link to comment
https://forums.phpfreaks.com/topic/180024-how-to-return-every-row-from/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.