Code: Select all
while($row_getReport = mysql_fetch_assoc($getReport)) {
$week_hours_row = "SELECT ((UNIX_TIMESTAMP( ma1 ) - UNIX_TIMESTAMP( ma2 )) / 3600),
((UNIX_TIMESTAMP( ti1 ) - UNIX_TIMESTAMP( ti2 )) / 3600),((UNIX_TIMESTAMP( ke1 ) - UNIX_TIMESTAMP( ke2 )) / 3600),
((UNIX_TIMESTAMP( to1 ) - UNIX_TIMESTAMP( to2 )) / 3600),((UNIX_TIMESTAMP( pe1 ) - UNIX_TIMESTAMP( pe2 )) / 3600),
((UNIX_TIMESTAMP( la1 ) - UNIX_TIMESTAMP( la2 )) / 3600),((UNIX_TIMESTAMP( su1 ) - UNIX_TIMESTAMP( su2 )) / 3600) AS hrs FROM workhours";
mysql_select_db($database_gntdb, $gntdb) or die(mysql_error());
$hours_in_week = mysql_query($week_hours_row) or die(mysql_error());
$get_hours_in_week = mysql_fetch_array($hours_in_week) or die(mysql_error());Code: Select all
$ma = abs($get_hours_in_weekї'0']);
if($ma > '7.5' && $ma < '8.0') { $ma_VKY = '8.0'-$ma; } elseif($ma > '8.0') { $ma_VKY = '0.5'; } else { $ma_VKY = '0.0'; }next the script prints out the values and closes while loop.
The prob is this: Its works out fine with ONE entry in DB, but of course with multiple entries (the way it goes...) those figures won't be realistic, due to multiple instances of same variables ( because of the while loop ).
For example, if i have two entries in DB, the first one has worked from monday to thursday, but the other one only from monday to tuesday, the print screws up like this:
Name: John Doe
MON: 8.75 VKY: 0.5
TUE: 8.97 VKY: 0.5
WED: 9.07 VKY: 0.5
THU: 5.5 VKY: 0.0
FRI: 0 VKY: 0.0
SAT: 0 VKY: 0.0
SUN: 0 VKY: 0.0
WEEK: 32.29 1.5
Name: Jane Doe
MON: 8.75 VKY: 0.5
TUE: 8.97 VKY: 0.5
WED: 9.07 VKY: 0.5
THU: 5.5 VKY: 0.0
FRI: 0 VKY: 0.0
SAT: 0 VKY: 0.0
SUN: 0 VKY: 0.0
WEEK: 32.29 1.5
U see what i mean? Each row is different in database, but the print is like this...
Anyone? Anything?