dreamwest Posted May 13, 2009 Share Posted May 13, 2009 Ive tried everything to get this to work, but it keeps displaying the same result over and over even though the column has new times added I have a column with time format : 12:50 4:30 1:20 etc... $query = "SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(length))) FROM table"; $result5 = mysql_query($query) or die(mysql_error()); $row5 = mysql_fetch_array($result5); $total_hours = $row5['SEC_TO_TIME(SUM(TIME_TO_SEC(length)))'] * 60 ; echo $total_hours; Quote Link to comment https://forums.phpfreaks.com/topic/157952-problem-with-sum/ Share on other sites More sharing options...
Ken2k7 Posted May 13, 2009 Share Posted May 13, 2009 And what are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/157952-problem-with-sum/#findComment-833216 Share on other sites More sharing options...
PFMaBiSmAd Posted May 13, 2009 Share Posted May 13, 2009 Your total hours calculation does not make sense for a couple of reasons. You are multiplying a number that has two different number bases minutes:seconds by 60 and to get hours you would generally need to divide the minutes by 60 to get the whole number of hours. Quote Link to comment https://forums.phpfreaks.com/topic/157952-problem-with-sum/#findComment-833220 Share on other sites More sharing options...
dreamwest Posted May 13, 2009 Author Share Posted May 13, 2009 Your total hours calculation does not make sense for a couple of reasons. You are multiplying a number that has two different number bases minutes:seconds by 60 and to get hours you would generally need to divide the minutes by 60 to get the whole number of hours. Ok this will get total minuets - before the deliminator ":" $query = "SELECT SUM((length) FROM table"; $result5 = mysql_query($query) or die(mysql_error()); $row5 = mysql_fetch_array($result5); $total_minuets = $row5['SUM(TIME_TO_SEC(length)'] ; echo $total_hours; But how can i get the sum of seconds after the ":" Quote Link to comment https://forums.phpfreaks.com/topic/157952-problem-with-sum/#findComment-833595 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.