adzie Posted September 17, 2007 Share Posted September 17, 2007 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 https://forums.phpfreaks.com/topic/69637-hours-total/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.