Jump to content

Possibly basic Mins to Hours Question


cloudsurferuk

Recommended Posts

Ok, Tried all I know but cant seem to get my head round this. Basically the following code looks at all the fields in one table (acars_pirep) for the specified crew member and displays the total of blocktime. However block time is a numerical figure representing minutes i.e. if they have flown 1hr 30mins the report shows 90. Now the code works fine and adds all the hours up and gives me a total value but this is obviously in the minutes form i.e. 90, now how can change the code so it converts 90 into 1:30 for display purposes?

 

Code being used

$query = "SELECT * FROM pilots ORDER BY pilot_num ASC";

$result = mysql_query($query);




$number = mysql_numrows($result);



if ($number > 0) {


print "<table>";

print "<tr>";

print "<td bgcolor=#CC6600 width=50 height=12 align=left><font face=Arial color=#000000 size=1><b>Pilot ID</b></font></td>";

print "<td bgcolor=#CC6600 width=150 height=12 align=left><font face=Arial color=#000000 size=1><b>Name</b></font></td>";

print "<td bgcolor=#CC6600 width=150 height=12 align=left><font face=Arial color=#000000 size=1><b>City</b></font></td>";

print "<td bgcolor=#CC6600 width=30 height=12 align=left><font face=Arial color=#000000 size=1><b>Loc</b></font></td>";

print "<td bgcolor=#CC6600 width=73 height=12 align=left><font face=Arial color=#000000 size=1><b>Total (Mins)</b></font></td>";

print "<td bgcolor=#CC6600 width=73 height=12 align=left><font face=Arial color=#000000 size=1><b>Rank</b></font></td>";

print "<td bgcolor=#CC6600 width=73 height=12 align=left><font face=Arial color=#000000 size=1><b>Prev Hours</b></font></td>";

print "</tr>";





for ($i=0; $i<$number; $i++) {

     		$num = mysql_result($result,$i,"pilot_num");

     		$name = mysql_result($result,$i, "name");

     		$city = mysql_result($result,$i, "city");

     		$country = mysql_result($result,$i, "country");

     		$status = mysql_result($result,$i, "status");

		$previous_hours = mysql_result($result,$i, "previous_hours");

	$id = mysql_result($result,$i, "pilot_id");


         	

	$query_hours = "SELECT sum(t2.blocktime) AS duration_sum FROM pilots t1, acars_pirep t2 WHERE t1.pilot_id=$id AND t1.pilot_id=t2.iduser";

    		$result_hours = mysql_query($query_hours);

    	

    		if (mysql_numrows($result_hours) > 0) {

		$time = mysql_result($result_hours,0,"duration_sum");

	}


     		

     		print "<tr>";

     		print "<td width=50 height=12 align=left><font face=Arial size=1 color=#000080><a href='crewcentre.php?focus=15&fsbid=$id'>$num</a></font></td>";

     		print "<td width=150 height=12 align=left><font face=Arial size=1 color=#000080><a href='crewcentre.php?focus=15&fsbid=$id'>$name</a></font></td>";

     		print "<td width=150 height=12 align=left><font face=Arial size=1 color=#000080>$city</font></td>";

     		print "<td width=30 height=12 align=left><font face=Arial size=1 color=#000080>$country</font></td>";

     		print "<td width=73 height=12 align=left><font face=Arial size=1 color=#000080>$time</font></td>";

     		print "<td width=73 height=12 align=left><font face=Arial size=1 color=#000080>$status</font></td>";

		print "<td width=73 height=12 align=left><font face=Arial size=1 color=#000080>$previous_hours</font></td>";

     		print "</tr>";

}



print "</table>";

}

Link to comment
https://forums.phpfreaks.com/topic/190636-possibly-basic-mins-to-hours-question/
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.