In the following code I have a loop that gives me a $total_time for a set series of actions.
example:
action_start = 10:00
action_end = 10:05
$total_time = 5 min
then it loops and goes on to the next set of actions
action_start = 12:00
action_end = 12:15
$total_time = 15 min
I need to keep a running tab of $complete_total_time
example:
$complete_total_time =
$total_time(loop 1)
+
$total_time(loop 2)
+
$total_time(loop 3)
and so on and so on
Code:$query4="SELECT * FROM job_log WHERE $table_id=table_id"; $last_value = ""; $result4=mysql_query($query4); while($row4 = mysql_fetch_assoc($result4)) { if ($action6=="Start Creation" || $action6=="Start Table PTG" || $action6=="Cutting - Begin" || $action6=="Begin 1st Proof" || $action6=="Proof Print - Begin" || $action6=="Start In-House Fix" || $action6=="Final Print - Begin" || $action6=="Start Outside Change"){ $start_action = $time_table4; $start_count++;} if ($action6=="Pause"){ $pause_time = $time_table4; $pause_count++; $start_action1 = $pause_time - $start_action;} if ($action6=="Resume"){ $resume_time = $time_table4; $resume_count++;} if ($action6=="End Creation" || $action6=="Finish Table PTG" || $action6=="Cutting - End" || $action6=="End 1st Proof -OK" || $action6=="End 1st Proof - FIX" || $action6=="End In-House Fix" || $action6=="Final Print - End" || $action6=="End Outside Change"){ $end_action = $time_table4; $end_count++; if ($end_count > $start_count){ $start_action = "0"; $start_count--;} if ($resume_count < $pause_count){ $sec = ($end_action - $start_action) + $start_action1; $hr = floor($sec/60/60); $sec = $sec - $hr * 60 * 60; $min = floor($sec/60); $sec = $sec - $min * 60; $total_time = sprintf("%02d:%02d:%02d", $hr, $min, $sec); $start_count = "0"; $end_count = "0"; $pause_count = "0"; $resume_count = "0"; $pause_time = "0"; $resume_time = "0"; if ($total_time > "05:00:00" || $total_time <= "00:00:00"){echo "";} else {echo "<center><table border = '0' cellspaceing = '0' cellpadding = '-1' width = '10%' bgcolor = '#999999'>"; echo "<tr><td align = 'center' width = '100%'>$total_time</td>"; echo "</tr></table></center>";}} $sec = ($end_action - $resume_time) + ($pause_time - $start_action); $hr = floor($sec/60/60); $sec = $sec - $hr * 60 * 60; $min = floor($sec/60); $sec = $sec - $min * 60; $total_time = sprintf("%02d:%02d:%02d", $hr, $min, $sec); $start_count = "0"; $end_count = "0"; $pause_count = "0"; $resume_count = "0"; $pause_time = "0"; $resume_time = "0"; if ($total_time > "05:00:00" || $total_time <= "00:00:00"){echo "";} else {echo "<center><table border = '0' cellspaceing = '0' cellpadding = '-1' width = '10%' bgcolor = '#999999'>"; echo "<tr><td align = 'center' width = '100%'>$total_time</td>"; echo "</tr></table></center>";}} else{ echo "";}






Bookmarks