multiplying

From: Date: Fri, 11 Apr 2003 15:40:51 +0000
Subject: multiplying
Groups: php.general 
Request: Send a blank email to php-general+get-143522@lists.php.net to get a copy of this message
I have this code to print many hours but it seems to be adding the hours in total user by user this is wierd $link = mysql_connect("localhost", "", "") or die("Could not connect"); mysql_select_db("cdmvirt_ft") or die("Could not select database"); $query = "SELECT * FROM pirep WHERE pilot_id='mvc007'"; $result = mysql_query($query) or die("Query failed"); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $hhmm=explode(':',$line['flight_hhmm']); $totalm+=$hhmm[0]*60+$hhmm[1]; $mvc007=floor($totalm / 60).':'.($totalm % 60); } mysql_free_result($result); $link = mysql_connect("localhost", "", "") or die("Could not connect"); mysql_select_db("cdmvirt_ft") or die("Could not select database"); $query = "SELECT flight_hhmm FROM pirep WHERE pilot_id='mvc069'"; $result = mysql_query($query) or die("Query failed"); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $hhmm=explode(':',$line['flight_hhmm']); $totalm+=$hhmm[0]*60+$hhmm[1]; } $mvc069=floor($totalm / 60).':'.($totalm % 60); mysql_free_result($result); $link = mysql_connect("localhost", "", "") or die("Could not connect"); mysql_select_db("cdmvirt_ft") or die("Could not select database"); $query = "SELECT flight_hhmm FROM pirep WHERE pilot_id='mvc101'"; $result = mysql_query($query) or die("Query failed"); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $hhmm=explode(':',$line['flight_hhmm']); $totalm+=$hhmm[0]*60+$hhmm[1]; } $mvc101=floor($totalm / 60).':'.($totalm % 60); mysql_free_result($result); if the first user has 10 hours the second has 20 this is what I get user1 = 10 user 2 = 30 and so on what am I doing wrong

« previous php.general (#143522) next »