Jump to content

confused with script here


thefollower

Recommended Posts

Im kinda confused here as to how to get this working, im trying to get my script to show the average time of all tasks done but it gives a value of like 184.0000000000 which is meaningless to me thus i don't know what that is telling me if its seconds/minutes/days etc :S?

 

 

This is what i got:

<?php
$GET = mysql_query("SELECT UserID, COUNT(TaskID) AS Total,AVG(timediff(CompletedOn,StartedOn)) AS AverageTime FROM usertasktable WHERE Complete='2' GROUP BY UserID ORDER BY Total DESC,AverageTime DESC LIMIT 20")
Or die(mysql_error());

While($row = mysql_fetch_assoc($GET)){
$UserID = $row['UserID'];
$Get2 = mysql_query("SELECT Username FROM userregistration WHERE UserID='$UserID'")
	Or die(mysql_error());
$row2 = mysql_fetch_assoc($Get2);
$Username = $row2['Username'];
$Total = $row['Total'];
$Time = $row['AverageTime'];

echo 'Name '.$Username .'['.$UserID.']';
echo 'Total Complete '.$Total;
echo 'Average Time : '.$Time;
}
?>

 

Its the average time that im having difficulties with here... hope you can help me out.

Link to comment
https://forums.phpfreaks.com/topic/125671-confused-with-script-here/
Share on other sites

The part thats generating this number.. Whats making this number "184.0000000000" if we know whats generating that number and how, we can then better help with an output thats a little more taliored to your needs  ;D

 

Thank you for your replies guys,

 

This is what is generating the number (from the mysql)

 

AVG(timediff(CompletedOn,StartedOn)) AS AverageTime

 

Imagine rows of timestamps of started and stops for different times.. it works out the time difference of the started and completed then works out the Average time of all them start and stop time differences.. which produced:

184.0000000000

 

 

My exact rows that it is using is:

Completed On                    Started On
2008-09-24 00:25:17    | 2008-09-19 15:16:03
2008-09-19 15:15:50    | 2008-09-14 01:58:32
2008-09-14 00:46:42    | 2008-09-14 00:43:03

 

 

 

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.