...

View Full Version : Listing data from array



Begbie
11-05-2009, 12:44 PM
Hello, I am new with php and I have a problem with listing data from array.
I have function getAllDates() where I collect all dates from my DB and
I have function getChefBar($datum, $schicht) where I get value ("bar")
for specific day that I need. These two functions are working correct.
So I tried to make another function (function getEarnedMoneyForDay ($datum))
where I want to get value that I need ("bar") for all days, but I have a very
little knowledge and I am failing to do so. When I type this getChefBar($dates[$datum]) I am getting nothing and my intention is to get
value for every day. So if please someone can tell me how to get this value form array. Thanks in advance ;)


<?php
function getAllDates(){
$selectAllDates = "SELECT s.datum, s.schicht FROM schichtumsatz s ORDER BY s.datum ASC, schicht DESC";
$dates = mysql_query($selectAllDates);
$row_dates = mysql_fetch_array($dates);

$result=array();

while ($row_dates) {
$result[] = $row_dates["datum"];
$row_dates = mysql_fetch_array($dates);
}
return $result;
}
function getChefBar($datum, $schicht){
$chef_data="SELECT s.datum, s.schicht, s.bargeld, s.kassiert, s.belege, s.gutschein, s.rechnung, s.sonstiges, s.umsatz
FROM schichtumsatz s
WHERE s.datum = ".$datum."
AND s.schicht = '".$schicht."'
ORDER BY s.datum ASC
";

$chef_query = mysql_query($chef_data);

while($row_chef = mysql_fetch_array($chef_query) ){

$eingegeben = $row_chef["bargeld"] + $row_chef["belege"] + $row_chef["gutschein"] + $row_chef["rechnung"] + $row_chef["sonstiges"];
$bar = $eingegeben - $row_chef["gutschein"] - $row_chef["rechnung"] - $row_chef["sonstiges"] - $row_chef["belege"];

}

return $bar;
}
function getEarnedMoneyForDay($datum){
$schichtA = 'A';
$schichtV='V';
$dates = getAllDates();

for($i=0;$i<$count;$i++){
echo $count .' ';
$partresult = getChefBar($dates[$datum],$schichtA);
$result = $result + $partresult;
}

return $result;
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum