Jump to content

hours total


adzie

Recommended Posts

I'm working on this script to total hours for each member group.

 

the script i have so far is below

 

the problem I have is on this line when i run the script and the results come us as zero hours

 

if (mysql_numrows($result_hours) > 0)

 

 

any thoughts?

 

$sql="select * from groups order by 'order' ASC";

$query = mysql_query($sql);

$msg .= "<table border=1 align=center><tr><td>group</td><td>Members</td><td>Hours</td><td>Average Hours</td></tr>";

while($row = mysql_fetch_row($query))

{

 

$query_hours = "SELECT sec_to_time(sum(time_to_sec(t2.duration))) AS duration_sum FROM members t1, member_drives t2 WHERE t1.active=1 AND t1.member_id=t2.member_id";

$result_hours = mysql_query($query_hours);   

if (mysql_numrows($result_hours) > 0)

{

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

}

else

{

$time = " ";

}

$sql2="select * from members where active=1";

$query2 = mysql_query($sql2);

$members = mysql_numrows($query2);

if($members == 0)

{

$avg = "0:00:00";

$time = "0:00:00";

}

else

{

$avg = $time/$members;

$avg = substr($avg,0, strpos($avg,".")+3);

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.